util/AllocatedString: add operator=()

This commit is contained in:
Max Kellermann 2021-01-14 13:35:24 +01:00 committed by Max Kellermann
parent b833c5d2c7
commit 99405a4c93
1 changed files with 14 additions and 0 deletions

View File

@ -100,6 +100,18 @@ public:
return *this; return *this;
} }
BasicAllocatedString &operator=(string_view src) noexcept {
delete[] std::exchange(value, nullptr);
value = Duplicate(src);
return *this;
}
BasicAllocatedString &operator=(const_pointer src) noexcept {
delete[] std::exchange(value, nullptr);
value = src != nullptr ? Duplicate(src) : nullptr;
return *this;
}
constexpr bool operator==(std::nullptr_t) const noexcept { constexpr bool operator==(std::nullptr_t) const noexcept {
return value == nullptr; return value == nullptr;
} }
@ -161,6 +173,8 @@ public:
AllocatedString() noexcept = default; AllocatedString() noexcept = default;
AllocatedString(BasicAllocatedString<value_type> &&src) noexcept AllocatedString(BasicAllocatedString<value_type> &&src) noexcept
:BasicAllocatedString(std::move(src)) {} :BasicAllocatedString(std::move(src)) {}
using BasicAllocatedString::operator=;
}; };
#endif #endif