From ebf3a6961e17434db6fbb9e0b358a4da0243cb79 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 21 Apr 2024 10:31:26 -0500 Subject: [PATCH] [ox/std] Add String constructor that takes a StringLiteral --- deps/ox/src/ox/std/string.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index 1c6f7651..af137802 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -15,6 +15,7 @@ #include "algorithm.hpp" #include "memops.hpp" #include "serialize.hpp" +#include "stringliteral.hpp" #include "stringview.hpp" #include "strops.hpp" #include "vector.hpp" @@ -41,6 +42,8 @@ class BasicString { constexpr BasicString(const char *str, std::size_t size) noexcept; + constexpr explicit BasicString(StringLiteral const&str) noexcept; + constexpr explicit BasicString(CRStringView str) noexcept; constexpr explicit BasicString(BasicString const&) noexcept; @@ -250,14 +253,6 @@ constexpr BasicString::BasicString(std::size_t cap) noexcept: } } -template -template -constexpr BasicString::BasicString(char const (&str)[Sz]) noexcept { - m_buff.resize(Sz + 1); - ox::listcpy(m_buff.data(), str, Sz); - m_buff[Sz] = 0; -} - template constexpr BasicString::BasicString(const char *str) noexcept { if (!m_buff.empty()) { @@ -285,6 +280,11 @@ constexpr BasicString::BasicString(const char *str, std::size m_buff[size] = 0; } +template +constexpr BasicString::BasicString(StringLiteral const&str) noexcept: + BasicString(StringView{str.data(), str.bytes()}) { +} + template constexpr BasicString::BasicString(CRStringView str) noexcept { if (m_buff.empty()) {