7 #include "arg_router/algorithm.hpp"
8 #include "arg_router/policy/policy.hpp"
18 struct is_second_element_policy_or_child {
19 using second_type = boost::mp11::mp_second<T>;
20 constexpr
static bool value = policy::is_policy_v<second_type> || is_tree_node_v<second_type>;
32 template <
typename Strings>
34 template <
typename Mapping>
35 using fn =
typename Mapping::template type<Strings>;
38 template <
typename U,
typename... I>
39 [[nodiscard]] constexpr
auto tuple_builder(U&& input, [[maybe_unused]] std::tuple<I...> Is) noexcept
41 return std::tuple{std::get<I::value>(std::forward<U>(input))...};
50 template <
template <
typename>
typename Policy>
53 template <
typename Strings>
55 using index = boost::mp11::mp_find_if<Strings, detail::multi_char_finder>;
56 using string_type = boost::mp11::mp_eval_if_c<index::value == std::tuple_size_v<Strings>,
61 using type = boost::mp11::
62 mp_eval_if_c<std::is_void_v<string_type>, string_type, Policy, string_type>;
67 template <
typename Strings>
68 using type =
typename inner<Strings>::type;
76 template <
template <
typename>
typename Policy>
79 template <
typename Strings>
81 constexpr
static std::size_t first_index =
82 boost::mp11::mp_find_if<Strings, detail::multi_char_finder>::value;
83 using dropped_first_strings =
84 boost::mp11::mp_eval_if_c<first_index == std::tuple_size_v<Strings>,
90 using index = boost::mp11::mp_find_if<dropped_first_strings, detail::multi_char_finder>;
92 boost::mp11::mp_eval_if_c<index::value == std::tuple_size_v<dropped_first_strings>,
95 dropped_first_strings,
97 using type = boost::mp11::
98 mp_eval_if_c<std::is_void_v<string_type>, string_type, Policy, string_type>;
103 template <
typename Strings>
104 using type =
typename inner<Strings>::type;
112 template <
template <
typename>
typename Policy>
115 template <
typename Strings>
117 using index = boost::mp11::mp_find_if<Strings, detail::single_char_finder>;
118 using string_type = boost::mp11::mp_eval_if_c<index::value == std::tuple_size_v<Strings>,
123 using type = boost::mp11::
124 mp_eval_if_c<std::is_void_v<string_type>, string_type, Policy, string_type>;
129 template <
typename Strings>
130 using type =
typename inner<Strings>::type;
138 template <
template <
typename>
typename Policy>
141 template <
typename Strings>
143 using string_type = boost::mp11::
144 mp_eval_if_c<(std::tuple_size_v<Strings> < 1),
void, boost::mp11::mp_first, Strings>;
145 using type = boost::mp11::
146 mp_eval_if_c<std::is_void_v<string_type>, string_type, Policy, string_type>;
151 template <
typename Strings>
152 using type =
typename inner<Strings>::type;
160 template <
template <
typename>
typename Policy>
163 template <
typename Strings>
165 using string_type = boost::mp11::
166 mp_eval_if_c<(std::tuple_size_v<Strings> < 2),
void, boost::mp11::mp_second, Strings>;
167 using type = boost::mp11::
168 mp_eval_if_c<std::is_void_v<string_type>, string_type, Policy, string_type>;
173 template <
typename Strings>
174 using type =
typename inner<Strings>::type;
185 template <
typename... Mappings,
typename... Params>
186 [[nodiscard]] constexpr
auto convert(Params&&... params) noexcept
190 std::tuple<std::decay_t<Params>...>>;
194 boost::mp11::mp_filter_q<boost::mp11::mp_not_fn<detail::string_finder>,
195 zipped>>::first_type;
200 boost::mp11::mp_filter<detail::string_finder, zipped>>::second_type;
204 using mapped_tuple = boost::mp11::mp_remove_if<
205 boost::mp11::mp_transform_q<detail::mapping_fn<strings>, std::tuple<Mappings...>>,
208 static_assert(std::tuple_size_v<strings> == std::tuple_size_v<mapped_tuple>,
209 "Unhandled bare strings passed");
211 return std::tuple_cat(
213 detail::tuple_builder(std::tuple{std::forward<Params>(params)...}, not_string_indices{}));
typename inner< Strings >::type type
typename inner< Strings >::type type
typename inner< Strings >::type type
typename inner< Strings >::type type
typename inner< Strings >::type type
typename zip< First, Second >::type zip_t
std::integral_constant< decltype(Value), Value > integral_constant
constexpr auto convert(Params &&... params) noexcept
constexpr std::size_t count(std::string_view str) noexcept