Further tweaks to StringViews.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9f5b8e9c83
commit
5994299baa
|
@ -65,14 +65,14 @@ namespace ArbUt {
|
|||
: BasicStringView(CalcLength(str), Hash(str)), _str(new __ConstStringCharHolder(str, CalcLength(str))) {}
|
||||
StringView(const char* str, size_t length) noexcept
|
||||
: BasicStringView(length, Hash(str)), _str(new __ConstStringCharHolder(str, length)) {}
|
||||
|
||||
StringView() noexcept : BasicStringView(0, Hash("")), _str(GetEmptyString()) {
|
||||
GetEmptyString()->AddReference();
|
||||
}
|
||||
StringView() noexcept : BasicStringView(0, Hash("")), _str(GetEmptyString()) { _str->AddReference(); }
|
||||
|
||||
/* Copy operators */
|
||||
StringView(const StringView& other) noexcept
|
||||
: 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 {
|
||||
if (_str == other._str) {
|
||||
_str->AddReference();
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace ArbUt {
|
|||
[[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::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 {
|
||||
return _hash == Hash(rhs.data());
|
||||
|
|
Loading…
Reference in New Issue