6 #ifndef DUNE_COMMON_TYPETREE_CHILDACCESS_HH 7 #define DUNE_COMMON_TYPETREE_CHILDACCESS_HH 10 #include <type_traits> 54 template<
typename Node,
typename... Indices>
57 if constexpr (
sizeof...(Indices) == 0)
58 return std::forward<Node>(node);
61 using I0 = std::tuple_element_t<0,
TreePath<Indices...>>;
63 static_assert(I0::value < std::decay_t<Node>::degree(),
"Child index out of range");
65 assert(std::size_t(treePath.front()) < node.degree() &&
"Child index out of range");
66 if constexpr (
sizeof...(Indices) == 1)
67 return node.child(treePath.front());
69 return child(node.child(treePath.front()), pop_front(treePath));
96 template<
typename Node,
typename... Indices>
97 decltype(
auto)
child (Node&& node, Indices... indices)
112 template<
typename Node, std::size_t... indices>
128 template<
typename Node, std::size_t... indices>
129 using Child =
typename Impl::ChildTraits<Node, indices...>::type;
139 template<
typename Node,
typename TreePath>
140 using ChildForTreePath = std::decay_t<decltype(child(std::declval<Node>(), std::declval<TreePath>()))>;
147 static constexpr
auto childTypes()
149 if constexpr (Dune::TypeTree::Concept::StaticDegreeInnerTreeNode<N>)
153 }, std::make_index_sequence<N::degree()>{});
171 using Children =
typename decltype(Impl::childTypes<N>())::type;
179 #endif // DUNE_COMMON_TYPETREE_CHILDACCESS_HH typename Impl::ChildTraits< Node, indices... >::type Child
Template alias for the type of a child node given by a list of child indices.
Definition: childaccess.hh:129
decltype(auto) constexpr unpackIntegerSequence(F &&f, [[maybe_unused]] std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition: indices.hh:124
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:29
I i
Definition: hybridmultiindex.hh:328
Definition: childaccess.hh:23
decltype(auto) child(Node &&node, TreePath< Indices... > treePath)
Extracts the child of a node given by a TreePath object.
Definition: childaccess.hh:55
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:383
std::decay_t< decltype(child(std::declval< Node >(), std::declval< TreePath >()))> ChildForTreePath
Template alias for the type of a child node given by a TreePath type.
Definition: childaccess.hh:140
A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:80
Traits for type conversions and type information.
A type that refers to another type.
Definition: typelist.hh:33