47 constexpr operator const char* ()
const noexcept {
return c_str(); }
59 constexpr bool empty() const noexcept {
return ptr ==
nullptr; }
62 void clear() {
if (ptr) release(); }
65 constexpr const char*
c_str() const noexcept {
return ptr ? (ptr +
sizeof(size_t)) :
nullptr; }
68 constexpr size_t size() const noexcept {
size_t size = 0;
if (ptr) { std::memcpy(&
size, ptr,
sizeof(
size)); }
return size; }
72 COGSFOUNDATION_API
void release();
76 static_assert(
sizeof(ImmutableString) ==
sizeof(
char*));
Represents a non-copyable immutable string.
constexpr ImmutableString & operator=(ImmutableString &&other) noexcept
Take ownership of another string.
constexpr void swap(ImmutableString &other) noexcept
Swap contents with another string.
constexpr const char * c_str() const noexcept
Get the string as C-string.
constexpr ImmutableString() noexcept=default
Create an empty string.
constexpr Cogs::StringView asView() const noexcept
Explicitly view the string as a string view.
constexpr size_t size() const noexcept
Get the string length.
constexpr bool empty() const noexcept
Check if string is empty.
~ImmutableString()
Destructor.
void clear()
Set contents to the empty string.
Provides a weakly referenced view over the contents of a string.
Contains all Cogs related functionality.