constexpr StrConst(const char (&str)[N])
static_assert(N > 1, "not a string");
constexpr operator const char*() const
constexpr size_t size() const
constexpr char operator[] (size_t i) const
return i < len_ ? str_[i] : throw std::out_of_range("invalid index");
I can use the results of caretPos to create a typedef for a std::tuple of std::integral_constants, where the size of the tuple is the number of carets found in the string, and each tuple element is an integral constant whose value is the position of the caret in the string.
Here I manually construct this tuple:
constexpr StrConst s("hello^world^");
constexpr int pos1 = caretPos(s);
constexpr int pos2 = caretPos(s, pos1+1);
using P1 = std::integral_constant<int, pos1>;
using P2 = std::integral_constant<int, pos2>;
using PosTuple = std::tuple<P1, P2>;
static_assert(std::tuple_element_t<0, PosTuple>::value == 5, "");
static_assert(std::tuple_element_t<1, PosTuple>::value == 11, "");