From 39498849bdf4c17bef0aee277bcb329b2a11c3c5 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 27 Apr 2020 16:14:38 +1000 Subject: [PATCH] Common/String: Support casting to std::string_View --- src/common/string.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/string.h b/src/common/string.h index a4a48ec6f..a0c1c7b9d 100644 --- a/src/common/string.h +++ b/src/common/string.h @@ -4,6 +4,7 @@ #include #include #include +#include // // 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)