Tatooine
concat_string_view.h
Go to the documentation of this file.
1#ifndef TATOOINE_CONCAT_STRING_VIEW_H
2#define TATOOINE_CONCAT_STRING_VIEW_H
3//==============================================================================
4#include <string_view>
5#include <utility>
6//==============================================================================
7namespace tatooine {
8//==============================================================================
9template <const char... cs>
11 static constexpr const char c_str[] = {cs..., '\0'};
12 static constexpr std::string_view value {c_str};
13};
14// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15template <const char... cs>
16static constexpr std::string_view c_str_assembler_v = c_str_assembler<cs...>::value;
17//==============================================================================
18template <std::string_view const& S0, std::string_view const& S1,
19 std::size_t... I0s, std::size_t... I1s>
20constexpr std::string_view const& concat(std::index_sequence<I0s...>,
21 std::index_sequence<I1s...>) {
22 return c_str_assembler_v<S0[I0s]..., S1[I1s]...>;
23}
24//------------------------------------------------------------------------------
25template <std::string_view const& S>
26constexpr std::string_view const& concat() {
27 return S;
28}
29//------------------------------------------------------------------------------
30template <std::string_view const& S0, std::string_view const& S1>
31constexpr std::string_view const& concat() {
32 return concat<S0, S1>(std::make_index_sequence<size(S0)>{},
33 std::make_index_sequence<size(S1)>{});
34}
35//------------------------------------------------------------------------------
36template <std::string_view const& S0, std::string_view const& S1,
37 std::string_view const& S2, std::string_view const&... Ss>
38constexpr std::string_view const& concat() {
39 return concat<S0, concat<S1, S2, Ss...>()>();
40}
41//==============================================================================
42} // namespace tatooine
43//==============================================================================
44#endif
Definition: algorithm.h:6
static constexpr std::string_view c_str_assembler_v
Definition: concat_string_view.h:16
auto size(vec< ValueType, N > const &v)
Definition: vec.h:148
constexpr std::string_view const & concat()
Definition: concat_string_view.h:26
Definition: concat_string_view.h:10
static constexpr const char c_str[]
Definition: concat_string_view.h:11
static constexpr std::string_view value
Definition: concat_string_view.h:12