git subrepo clone (merge) git@github.com:Rconybea/xo-flatstring xo-flatstring

subrepo:
  subdir:   "xo-flatstring"
  merged:   "996c220e"
upstream:
  origin:   "git@github.com:Rconybea/xo-flatstring"
  branch:   "main"
  commit:   "996c220e"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
This commit is contained in:
Roland Conybeare 2026-06-06 21:34:32 -04:00
commit fa57de89fe
32 changed files with 2529 additions and 0 deletions

View file

@ -0,0 +1,30 @@
#include <string_view>
#include <array>
template <std::string_view const & ... Strings>
struct sv_concat
{
static constexpr auto impl() noexcept {
constexpr std::size_t n = (Strings.size() + ... + 0);
std::array<char, n + 1> arr{};
auto append = [i=0, &arr](const auto & s) mutable {
for (auto c : s)
arr[i++] = c;
};
(append(Strings), ...);
arr[n] = '\0';
return arr;
}
static constexpr auto arr = impl();
static constexpr std::string_view value {
arr.data(),
arr.size() - 1
};
};
template <std::string_view const & ... Strings>
static constexpr auto concat_v = sv_concat<Strings...>::value;