7 #include "arg_router/tree_node.hpp"
8 #include "arg_router/utility/tuple_iterator.hpp"
15 template <
typename...>
16 [[nodiscard]] constexpr
static bool fn() noexcept
22 template <
typename Visitor,
typename Current,
typename... Parents>
23 constexpr
void tree_recursor_impl(Visitor& visitor,
24 const Current& current,
25 const Parents&... parents)
27 visitor(current, parents...);
30 [&](
auto ,
const auto& child) {
31 tree_recursor_impl(visitor, child, current, parents...);
36 template <
typename Visitor,
typename SkipFn,
typename Current,
typename... Parents>
37 constexpr
void tree_type_recursor_impl()
39 if constexpr (!SkipFn::template fn<Current, Parents...>()) {
40 Visitor::template fn<Current, Parents...>();
42 if constexpr (is_tree_node_v<Current>) {
43 using policies_and_children_tuple =
44 boost::mp11::mp_append<
typename Current::policies_type,
45 typename Current::children_type>;
47 tuple_type_iterator<policies_and_children_tuple>([](
auto i) {
48 using next_type = std::tuple_element_t<i, policies_and_children_tuple>;
49 tree_type_recursor_impl<Visitor, SkipFn, next_type, Current, Parents...>();
55 template <
template <
typename...>
typename Visitor,
typename Current,
typename... Parents>
56 struct tree_type_recursor_collector_impl {
57 template <
typename ChildOrPolicy>
59 typename tree_type_recursor_collector_impl<Visitor, ChildOrPolicy, Current, Parents...>::
63 using get_children_type =
typename T::children_type;
65 using get_policies_type =
typename T::policies_type;
67 using children_type = boost::mp11::
68 mp_eval_if_c<!is_tree_node_v<Current>, std::tuple<>, get_children_type, Current>;
69 using policies_type = boost::mp11::
70 mp_eval_if_c<!is_tree_node_v<Current>, std::tuple<>, get_policies_type, Current>;
73 boost::mp11::mp_eval_if_c<!is_tree_node_v<Current>,
74 std::tuple<
typename Visitor<Current, Parents...>::type>,
75 boost::mp11::mp_push_back,
76 boost::mp11::mp_flatten<boost::mp11::mp_transform<
78 boost::mp11::mp_append<children_type, policies_type>>>,
79 typename Visitor<Current, Parents...>::type>;
101 template <
typename Visitor,
typename Root>
104 detail::tree_recursor_impl(visitor,
root);
144 template <
typename Visitor,
typename SkipFn,
typename Root>
147 detail::tree_type_recursor_impl<Visitor, SkipFn, Root>();
155 template <
typename Visitor,
typename Root>
158 detail::tree_type_recursor_impl<Visitor, detail::always_false, Root>();
176 template <
template <
typename...>
typename Visitor,
typename Root>
179 using type =
typename detail::tree_type_recursor_collector_impl<Visitor, Root>::type;
187 template <
template <
typename...>
typename Visitor,
typename Root>
constexpr void tree_recursor(Visitor visitor, const Root &root)
constexpr void tree_type_recursor()
typename tree_type_recursor_collector< Visitor, Root >::type tree_type_recursor_collector_t
constexpr std::enable_if_t< traits::is_tuple_like_v< std::decay_t< Tuple > > > tuple_iterator(F &&f, Tuple &&tuple)
constexpr auto root(Params... params) noexcept
typename detail::tree_type_recursor_collector_impl< Visitor, Root >::type type