From d5747dde17fab6d0c100d558c32a8bd0532eafc3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 18 Apr 2024 17:24:22 -0400 Subject: [PATCH] xo-flatstring: + from_flatstring() + from_chars() --- include/xo/flatstring/flatstring.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/xo/flatstring/flatstring.hpp b/include/xo/flatstring/flatstring.hpp index 41bfffa3..da80014b 100644 --- a/include/xo/flatstring/flatstring.hpp +++ b/include/xo/flatstring/flatstring.hpp @@ -168,6 +168,26 @@ namespace xo { } ///@} + /** @brief construct from another flatstring **/ + template + static constexpr flatstring from_flatstring(const flatstring & str) noexcept { + flatstring retval; + + retval.assign(str); + + return retval; + } + + /** @brief construct from char array **/ + template + static constexpr flatstring from_chars(const char (&str)[N2]) noexcept { + flatstring retval; + + retval.assign(str); + + return retval; + } + /** @brief construct from integer **/ static constexpr flatstring from_int(int x) { constexpr size_t buf_z = 20;