Common/String: Support casting to std::string_View

This commit is contained in:
Connor McLaughlin 2020-04-27 16:14:38 +10:00
parent 36444b264f
commit 39498849bd
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <cstdarg>
#include <cstring>
#include <limits>
#include <string_view>
//
// String
@ -221,6 +222,10 @@ public:
// m_pStringData->pBuffer[i]; }
operator const char*() const { return GetCharArray(); }
operator char*() { return GetWriteableCharArray(); }
operator std::string_view() const
{
return IsEmpty() ? std::string_view() : std::string_view(GetCharArray(), GetLength());
}
// Will use the string data provided.
String& operator=(const String& copyString)