7 #include "arg_router/tree_node_fwd.hpp"
9 #include <boost/mp11/algorithm.hpp>
10 #include <boost/mp11/bind.hpp>
11 #include <boost/mp11/utility.hpp>
18 #include <type_traits>
24 template <
typename... T>
25 struct tuple_size<boost::mp11::mp_list<T...>> : std::integral_constant<std::size_t, sizeof...(T)> {
28 template <std::size_t I,
typename... T>
29 struct tuple_element<I, boost::mp11::mp_list<T...>> {
30 using type = boost::mp11::mp_at_c<boost::mp11::mp_list<T...>, I>;
37 class multi_lang_exception;
46 template <
typename... T>
54 template <
typename... T>
77 constexpr
static bool value = boost::mp11::mp_valid<get_value_type, T>::value;
91 template <
typename T,
typename Enable =
void>
98 using type = std::underlying_type_t<T>;
105 template <
typename T>
114 template <
typename T,
typename =
void>
118 template <
typename T>
119 struct is_tuple_like<T, std::void_t<typename std::tuple_size<T>::type>> : std::true_type {
126 template <
typename T>
135 template <
typename T>
139 template <
template <
typename...>
typename U,
typename... Args>
147 template <
typename T>
161 template <
typename T,
template <
typename...>
typename U>
165 template <
template <
typename...>
typename U,
typename... Args>
174 template <
typename T,
template <
typename...>
typename U>
189 template <
typename T,
typename U,
typename... Args>
193 template <
template <
typename...>
typename T,
typename U,
typename... Args>
202 template <
typename T,
typename U>
209 template <auto Value>
216 template <
typename T>
218 using type = std::optional<T>;
225 template <
typename T>
234 template <
typename T>
237 static_assert(always_false_v<T>,
"T must be a tuple-like type");
240 template <
template <
typename...>
typename T,
typename... Params>
244 template <std::size_t... I>
247 [[maybe_unused]] std::integer_sequence<std::size_t, I...> Is) noexcept :
248 Params{std::get<I>(std::move(params))}...
254 template <std::size_t... I>
255 constexpr
explicit unpack_and_derive(
256 [[maybe_unused]] T<Params...> t,
257 [[maybe_unused]] std::integer_sequence<std::size_t> Is) noexcept
262 constexpr
explicit unpack_and_derive(T<Params...> params) noexcept :
263 unpack_and_derive{std::move(params), std::make_index_sequence<
sizeof...(Params)>{}}
273 template <
typename From,
typename To>
275 template <
typename F,
typename T>
276 using type = decltype(
static_cast<T
>(std::declval<F>()));
278 constexpr
static bool value = boost::mp11::mp_valid<type, From, To>::value;
286 template <
typename From,
typename To>
293 template <
typename T>
295 template <
typename U>
296 using type = decltype(U::long_name());
298 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
305 template <
typename T>
312 template <
typename T>
314 template <
typename U>
315 using type = decltype(U::short_name());
317 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
324 template <
typename T>
331 template <
typename T>
333 template <
typename U>
334 using type = decltype(U::display_name());
336 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
343 template <
typename T>
350 template <
typename T>
352 template <
typename U>
353 using type = decltype(U::none_name());
355 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
362 template <
typename T>
369 template <
typename T>
371 template <
typename U>
372 using type = decltype(U::error_name());
374 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
381 template <
typename T>
388 template <
typename T>
390 template <
typename U>
391 using type = decltype(U::description());
393 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
400 template <
typename T>
407 template <
typename T>
409 template <
typename U>
410 using type = decltype(U::value_separator());
412 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
419 template <
typename T>
426 template <
typename T>
428 template <
typename U>
429 using type = decltype(U::token_end_marker());
431 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
438 template <
typename T>
445 template <
typename T>
447 template <
typename U>
448 using type = decltype(U::maximum_count());
450 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
457 template <
typename T>
464 template <
typename T>
466 template <
typename U>
467 using type = decltype(U::minimum_count());
469 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
476 template <
typename T>
483 template <
typename T>
485 template <
typename U>
486 using type = decltype(U::minimum_value());
488 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
495 template <
typename T>
502 template <
typename T>
504 template <
typename U>
505 using type = decltype(U::maximum_value());
507 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
514 template <
typename T>
521 template <
typename T>
523 template <
typename U>
524 using type = decltype(std::declval<U&>().push_back(std::declval<typename U::value_type>()));
526 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
533 template <
typename T>
540 template <
typename T>
542 template <
typename U>
543 using type =
typename U::template help_data_type<false>;
545 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
552 template <
typename T>
559 template <
typename T>
562 struct fake_tree_node {
563 [[nodiscard]]
const std::tuple<>& children()
const {
return children_; }
565 std::tuple<> children_;
568 template <
typename U>
570 decltype(U::runtime_children(std::declval<const fake_tree_node&>(),
571 std::declval<std::function<
bool(
const fake_tree_node&)>>()));
574 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
581 template <
typename T>
589 template <
typename T>
591 template <
typename U>
592 using type = decltype(U::template generate_help<U, U, false>(std::declval<std::ostream&>()));
594 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
601 template <
typename T>
609 template <
typename T>
611 template <
typename U>
613 decltype(U::template generate_help<U, U, false>(std::declval<std::ostream&>(),
614 std::declval<const runtime_help_data&>()));
616 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
623 template <
typename T>
631 template <
typename T>
633 template <
typename U>
634 using type = decltype(std::declval<const T&>().
template generate_runtime_help_data<true, U>(
635 std::declval<const U&>()));
637 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
644 template <
typename T>
652 template <
typename T>
654 template <
typename U>
655 using type = decltype(std::declval<const U&>().runtime_enabled());
657 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
664 template <
typename T>
671 template <
typename T>
673 template <
typename U>
674 using type = decltype(U::translate_exception(std::declval<const multi_lang_exception&>()));
676 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
683 template <
typename T>
690 template <
typename T>
692 template <
typename U>
693 using type =
typename U::error_code_translations;
695 constexpr
static bool value = boost::mp11::mp_valid<type, T>::value;
702 template <
typename T>
703 constexpr
static bool has_error_code_translations_type_v =
717 template <
typename T>
721 template <
typename R,
typename... Args>
723 using type = std::tuple<R, Args...>;
725 template <
typename R,
typename C,
typename... Args>
726 struct arg_extractor<R (C::*)(Args...)> {
727 using type = std::tuple<R, Args...>;
729 template <
typename R,
typename C,
typename... Args>
730 struct arg_extractor<R (C::*)(Args...) const> {
731 using type = std::tuple<R, Args...>;
733 template <
typename R,
typename C,
typename... Args>
734 struct arg_extractor<R (C::*)(Args...) noexcept> {
735 using type = std::tuple<R, Args...>;
737 template <
typename R,
typename C,
typename... Args>
738 struct arg_extractor<R (C::*)(Args...) const noexcept> {
739 using type = std::tuple<R, Args...>;
746 template <
typename T>
753 template <
typename T>
754 constexpr std::size_t
arity_v = std::tuple_size_v<arg_extractor_t<T>> - 1;
761 template <
typename T, std::
size_t I>
constexpr bool has_generate_help_method_v
constexpr bool has_token_end_marker_method_v
constexpr bool is_specialisation_of_v
constexpr bool is_same_when_despecialised_v
constexpr bool has_error_name_method_v
constexpr bool has_runtime_generate_help_method_v
constexpr bool supports_static_cast_conversion_v
constexpr bool has_description_method_v
constexpr bool has_maximum_value_method_v
constexpr bool has_runtime_enabled_method_v
constexpr bool has_maximum_count_method_v
constexpr bool is_tuple_like_v
constexpr bool has_value_type_v
constexpr std::size_t arity_v
constexpr bool has_minimum_count_method_v
typename T::type get_type
constexpr bool has_none_name_method_v
constexpr bool has_runtime_children_method_v
constexpr bool has_generate_runtime_help_data_method_v
typename add_optional< T >::type add_optional_t
constexpr bool has_minimum_value_method_v
constexpr bool always_false_v
std::integral_constant< decltype(Value), Value > integral_constant
typename underlying_type< T >::type underlying_type_t
constexpr bool has_short_name_method_v
typename T::value_type get_value_type
typename arg_extractor< T >::type arg_extractor_t
constexpr bool has_long_name_method_v
constexpr bool has_display_name_method_v
constexpr bool is_specialisation_v
constexpr bool has_push_back_method_v
constexpr bool has_value_separator_method_v
std::tuple_element_t< I+1, arg_extractor_t< T > > arg_type_at_index
constexpr bool has_help_data_type_v