Ase::CString class final

Compact, deduplicating string variant for constant strings.

Public static functions

static auto lookup(const std::string& s) →  CString

Public functions

auto assign(const std::string& s) →  CString& noexcept
auto string() const →  const std::string&
Convert CString into a std::string.

Function documentation

static CString Ase::CString::lookup(const std::string& s)

Lookup a previously existing CString for a std::string s. If s has never been assigned to a CString before, the returned CString is empty. In constrast to assign(), no new memory is allocated.

CString& Ase::CString::assign(const std::string& s) noexcept

Assign a std::string to a CString, after deduplication, its memory is never released. In contrast to lookup(), the resulting CString is guaranteed to resolve to the contents of std::string s, memory is allocated if needed. Note that CString::assign() is not particularly fast, use it only to save memory for strings that are known to persist throughout runtime.