Further tweaks to ConstString.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-21 17:06:49 +02:00
parent 5e3b067452
commit 91b9854932
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 9 additions and 6 deletions

View File

@ -24,6 +24,10 @@
} \
\
inline static int constexpr Length(const char* str) { return *str ? 1 + Length(str + 1) : 0; } \
inline __ConstStringCharHolder* CloneHolder() const noexcept { \
_str->AddReference(); \
return _str; \
} \
\
public: \
name(const char* str, size_t size) \
@ -32,15 +36,14 @@
name() : _str(GetEmptyString()), _length(0), _hash(Hash("")) { GetEmptyString()->AddReference(); }; \
explicit name(const char* str) : name(str, Length(str)){}; \
explicit name(const std::string& str) : name(str.c_str(), str.size()){}; \
name(const name& other) : _str(other._str), _length(other._length), _hash(other._hash) { \
_str->AddReference(); \
} \
name(const name& other) : _str(other.CloneHolder()), _length(other._length), _hash(other._hash) {} \
name& operator=(const name& other) { \
if (_str == other._str) \
if (_str == other._str) { \
_str->AddReference(); \
return *this; \
} \
_str->RemoveReference(); \
_str = other._str; \
_str->AddReference(); \
_str = other.CloneHolder(); \
_length = other._length; \
_hash = other._hash; \
return *this; \