7 #include "arg_router/parsing/dynamic_token_adapter.hpp"
8 #include "arg_router/parsing/parse_target.hpp"
9 #include "arg_router/utility/compile_time_optional.hpp"
11 #include <boost/mp11/algorithm.hpp>
12 #include <boost/mp11/bind.hpp>
14 #include <type_traits>
29 template <
typename T,
typename... Args>
44 template <
typename Tuple>
52 template <
typename Tuple>
61 static_assert(policy::is_policy_v<T>,
"T must be a policy");
64 using type = decltype(
65 std::declval<const U&>().
template pre_parse_phase<>(
66 std::declval<parsing::dynamic_token_adapter&>(),
68 std::declval<parsing::parse_target&>()));
70 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
85 template <
typename T,
typename ValueType>
87 static_assert(policy::is_policy_v<T>,
"T must be a policy");
90 using type = decltype(
91 std::declval<const U&>().
template parse_phase<ValueType>(std::declval<std::string_view>()));
93 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
101 template <
typename T,
typename ValueType>
109 template <
typename T,
typename ValueType>
111 static_assert(policy::is_policy_v<T>,
"T must be a policy");
113 template <
typename U>
114 using type1 = decltype(
115 std::declval<const U&>().
template validation_phase<ValueType>(
116 std::declval<const ValueType&>()));
118 template <
typename U>
119 using type2 = decltype(
120 std::declval<const U&>().validation_phase(std::declval<const ValueType&>()));
122 constexpr
static bool value =
123 boost::mp11::mp_valid<type1, T>::value || boost::mp11::mp_valid<type2, T>::value;
131 template <
typename T,
typename ValueType>
132 constexpr
static bool has_validation_phase_method_v =
139 template <
typename T>
141 static_assert(policy::is_policy_v<T>,
"T must be a policy");
143 template <
typename U>
144 using type = decltype(std::declval<const U&>().
template routing_phase<>());
146 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
153 template <
typename T>
161 template <
typename T,
typename ValueType>
163 static_assert(policy::is_policy_v<T>,
"T must be a policy");
165 template <
typename U>
166 using type = decltype(
167 std::declval<const U&>().
template missing_phase<ValueType>());
169 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
177 template <
typename T,
typename ValueType>
184 template <
typename T>
186 static_assert(policy::is_policy_v<T>,
"T must be a policy");
188 template <
typename U>
189 using type = decltype(U::priority);
191 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
198 template <
typename T>
206 template <
typename ParentsTuple>
209 template <
typename Parent>
210 struct policy_finder {
211 constexpr
static bool value =
212 boost::mp11::mp_find_if_q<
213 typename Parent::policies_type,
214 boost::mp11::mp_bind<has_routing_phase_method, boost::mp11::_1>>::value !=
215 std::tuple_size_v<typename Parent::policies_type>;
221 using index = boost::mp11::mp_find_if<ParentsTuple, policy_finder>;
224 using type = boost::mp11::mp_eval_if_c<index::value == std::tuple_size_v<ParentsTuple>,
boost::mp11::mp_find_if< ParentsTuple, policy_finder > index
boost::mp11::mp_eval_if_c< index::value==std::tuple_size_v< ParentsTuple >, void, boost::mp11::mp_at, ParentsTuple, index > type
constexpr auto is_policy_v
constexpr auto is_all_policies_v