xo-flatstring: + from_flatstring() + from_chars()

This commit is contained in:
Roland Conybeare 2024-04-18 17:24:22 -04:00
commit d5747dde17

View file

@ -168,6 +168,26 @@ namespace xo {
}
///@}
/** @brief construct from another flatstring **/
template <std::size_t N2>
static constexpr flatstring from_flatstring(const flatstring<N2> & str) noexcept {
flatstring retval;
retval.assign(str);
return retval;
}
/** @brief construct from char array **/
template <std::size_t N2>
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;