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

This commit is contained in:
Deukhoofd 2020-06-27 15:15:13 +02:00
parent 9f5b8e9c83
commit 5994299baa
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 5 additions and 5 deletions

View File

@ -65,14 +65,14 @@ namespace ArbUt {
: BasicStringView(CalcLength(str), Hash(str)), _str(new __ConstStringCharHolder(str, CalcLength(str))) {} : BasicStringView(CalcLength(str), Hash(str)), _str(new __ConstStringCharHolder(str, CalcLength(str))) {}
StringView(const char* str, size_t length) noexcept StringView(const char* str, size_t length) noexcept
: BasicStringView(length, Hash(str)), _str(new __ConstStringCharHolder(str, length)) {} : BasicStringView(length, Hash(str)), _str(new __ConstStringCharHolder(str, length)) {}
StringView() noexcept : BasicStringView(0, Hash("")), _str(GetEmptyString()) { _str->AddReference(); }
StringView() noexcept : BasicStringView(0, Hash("")), _str(GetEmptyString()) {
GetEmptyString()->AddReference();
}
/* Copy operators */ /* Copy operators */
StringView(const StringView& other) noexcept StringView(const StringView& other) noexcept
: BasicStringView(other._length, other._hash), _str(other.CloneHolder()) {} : BasicStringView(other._length, other._hash), _str(other.CloneHolder()) {}
StringView(const BasicStringView& other, const char* c, size_t length) noexcept
: BasicStringView(length, other.GetHash()), _str(new __ConstStringCharHolder(c, length)) {}
StringView& operator=(const StringView& other) noexcept { StringView& operator=(const StringView& other) noexcept {
if (_str == other._str) { if (_str == other._str) {
_str->AddReference(); _str->AddReference();

View File

@ -17,7 +17,7 @@ namespace ArbUt {
[[nodiscard]] inline constexpr const char* c_str() const noexcept { return _str; } [[nodiscard]] inline constexpr const char* c_str() const noexcept { return _str; }
constexpr std::string_view std_str() const noexcept { return std::string_view(_str, _length); } constexpr std::string_view std_str() const noexcept { return std::string_view(_str, _length); }
constexpr std::size_t operator()(StringViewLiteral const& s) const noexcept { return s.GetHash(); } constexpr std::size_t operator()(StringViewLiteral const& s) const noexcept { return s.GetHash(); }
inline operator StringView() const noexcept { return StringView(_str, _length); } inline operator StringView() const noexcept { return StringView(*this, _str, _length); }
inline constexpr bool operator==(const std::string_view& rhs) const noexcept { inline constexpr bool operator==(const std::string_view& rhs) const noexcept {
return _hash == Hash(rhs.data()); return _hash == Hash(rhs.data());