8#include "fixed_string.hpp"
18template<basic_fixed_string Head, basic_fixed_string... Tail>
21 if constexpr (
sizeof...(Tail) > 0) {
22 return index == 0 ? Head : tag_at_index_impl<Tail...>(index - 1);
31template<basic_fixed_string... Tags>
34 if constexpr (
sizeof...(Tags) > 0) {
35 return tag_at_index_impl<Tags...>(index);
41template<basic_fixed_string Head, basic_fixed_string... Tail>
42size_t index_of_tag_impl(
std::string tag,
size_t index)
noexcept
44 if constexpr (
sizeof...(Tail) > 0) {
45 return tag == Head ? index : index_of_tag_impl<Tail...>(tag, index + 1);
47 return tag == Head ? index : index + 1;
54template<basic_fixed_string... Tags>
57 if constexpr (
sizeof...(Tags) > 0) {
58 return index_of_tag_impl<Tags...>(tag, 0);
64template<basic_fixed_string Needle, basic_fixed_string Head, basic_fixed_string... Tail>
65constexpr size_t index_of_tag_impl(
size_t index)
noexcept
67 if constexpr (
sizeof...(Tail) > 0) {
68 return Needle == Head ? index : index_of_tag_impl<Needle,Tail...>(index + 1);
70 return Needle == Head ? index : index + 1;
77template<basic_fixed_string Needle, basic_fixed_string... Haystack>
78constexpr size_t index_of_tag() noexcept
80 if constexpr (
sizeof...(Haystack) > 0) {
81 return index_of_tag_impl<Needle, Haystack...>(0);
87template<basic_fixed_string Needle, basic_fixed_string... Haystack>
88constexpr bool has_tag() noexcept {
89 return index_of_tag<Needle, Haystack...>() <
sizeof...(Haystack);
92template<basic_fixed_string... Haystack>
94 return index_of_tag<Haystack...>(needle) <
sizeof...(Haystack);