mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Use size_t for String size types
This commit is contained in:
		| @@ -7,6 +7,8 @@ | ||||
| #ifndef CATCH_STRING_H_INCLUDED | ||||
| #define CATCH_STRING_H_INCLUDED | ||||
|  | ||||
| #include <cstddef> | ||||
|  | ||||
| namespace Catch { | ||||
|      | ||||
|     class StringData; | ||||
| @@ -22,7 +24,7 @@ namespace Catch { | ||||
|  | ||||
|         StringData const* m_data = nullptr; | ||||
|     public: | ||||
|         using size_type = unsigned long; | ||||
|         using size_type = size_t; | ||||
|          | ||||
|         String(); | ||||
|         String( StringRef const& stringRef ); | ||||
|   | ||||
| @@ -9,6 +9,8 @@ | ||||
|  | ||||
| #include "catch_stringref.h" | ||||
|  | ||||
| #include <cstddef> | ||||
|  | ||||
| namespace Catch { | ||||
|  | ||||
|     class String; | ||||
| @@ -22,7 +24,7 @@ namespace Catch { | ||||
|     class StringBuilder { | ||||
|         friend class String; | ||||
|     public: | ||||
|         using size_type = unsigned long; | ||||
|         using size_type = size_t; | ||||
|          | ||||
|         StringBuilder(); | ||||
|         StringBuilder( size_type initialCapacity ); | ||||
|   | ||||
| @@ -21,7 +21,7 @@ namespace Catch { | ||||
|     auto StringData::create( StringRef const& stringRef ) -> StringData* { | ||||
|         return create( stringRef, stringRef.size() ); | ||||
|     } | ||||
|     auto StringData::create( StringRef const& stringRef, unsigned long capacity ) -> StringData* { | ||||
|     auto StringData::create( StringRef const& stringRef, size_t capacity ) -> StringData* { | ||||
|         if( capacity == 0 ) { | ||||
|             return getEmpty(); | ||||
|         } | ||||
| @@ -37,7 +37,7 @@ namespace Catch { | ||||
|     :   m_refs( initialRef ), | ||||
|         size( 0 ) | ||||
|     {} | ||||
|     StringData::StringData( StringRef const& stringRef, unsigned long capacity ) | ||||
|     StringData::StringData( StringRef const& stringRef, size_t capacity ) | ||||
|     :   m_refs( 1 ), | ||||
|         size( capacity) | ||||
|     { | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
| #define CATCH_STRINGDATA_H_INCLUDED | ||||
|  | ||||
| #include <atomic> | ||||
| #include <cstddef> | ||||
|  | ||||
| namespace Catch { | ||||
|      | ||||
| @@ -16,7 +17,7 @@ namespace Catch { | ||||
|     class StringData { | ||||
|         mutable std::atomic<unsigned int> m_refs; | ||||
|     public: | ||||
|         unsigned int size; | ||||
|         size_t size; | ||||
|         union { | ||||
|             char chars[1]; | ||||
|         }; | ||||
| @@ -26,7 +27,7 @@ namespace Catch { | ||||
|         } | ||||
|         static auto getEmpty() -> StringData*; | ||||
|         static auto create( StringRef const& stringRef ) -> StringData*; | ||||
|         static auto create( StringRef const& stringRef, unsigned long capacity ) -> StringData*; | ||||
|         static auto create( StringRef const& stringRef, size_t capacity ) -> StringData*; | ||||
|  | ||||
|         void addRef() const noexcept { | ||||
|             if( m_refs > 0 ) | ||||
| @@ -41,7 +42,7 @@ namespace Catch { | ||||
|         } | ||||
|     private: | ||||
|         StringData( unsigned int initialRef = 1 ); | ||||
|         StringData( StringRef const& stringRef, unsigned long capacity ); | ||||
|         StringData( StringRef const& stringRef, size_t capacity ); | ||||
|          | ||||
|         StringData( StringData const& ) = delete; | ||||
|         StringData& operator=( StringData const& ) = delete; | ||||
|   | ||||
| @@ -7,6 +7,8 @@ | ||||
| #ifndef CATCH_STRINGREF_H_INCLUDED | ||||
| #define CATCH_STRINGREF_H_INCLUDED | ||||
|  | ||||
| #include <cstddef> | ||||
|  | ||||
| namespace Catch { | ||||
|      | ||||
|     class String; | ||||
| @@ -24,7 +26,7 @@ namespace Catch { | ||||
|         friend class StringData; | ||||
|         friend class StringBuilder; | ||||
|  | ||||
|         using size_type = unsigned long; | ||||
|         using size_type = size_t; | ||||
|          | ||||
|         char const* m_start; | ||||
|         size_type m_size; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash