From aeae3fbf5afa691291f7cb46f545f0292db34e12 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 28 May 2022 03:19:50 -0500 Subject: [PATCH] [ox/std] Add operator std::string and operator const char* to String (synced from 779b18e41011fcd6a7c9f718d7dfbe8d297fda8f) --- src/ox/std/string.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ox/std/string.hpp b/src/ox/std/string.hpp index 6714eec42..5cd9d2150 100644 --- a/src/ox/std/string.hpp +++ b/src/ox/std/string.hpp @@ -193,11 +193,21 @@ class BasicString { return static_cast(m_buff.data()); } + [[nodiscard]] + inline explicit operator const char*() const { + return c_str(); + } + #ifdef OX_USE_STDLIB [[nodiscard]] inline std::string toStdString() const { return c_str(); } + + [[nodiscard]] + inline explicit operator std::string() const { + return c_str(); + } #endif /** @@ -271,8 +281,7 @@ constexpr BasicString::BasicString(const BasicString &other) no } template -constexpr BasicString::BasicString(BasicString &&other) noexcept { - m_buff = std::move(other.m_buff); +constexpr BasicString::BasicString(BasicString &&other) noexcept: m_buff(std::move(other.m_buff)) { } template