6#ifndef DUNE_TYPETREE_CHILDEXTRACTION_HH
7#define DUNE_TYPETREE_CHILDEXTRACTION_HH
13#include <dune/common/documentation.hh>
14#include <dune/common/indices.hh>
15#include <dune/common/typetraits.hh>
16#include <dune/common/shared_ptr.hh>
18#include <dune/common/typetree/childaccess.hh>
31 template <
class Node,
class Index>
32 std::true_type checkChildIndex (Node
const& node, Index i)
34 assert(std::size_t(i) < node.degree() &&
"Child index out of range");
39 template <
class Node, std::
size_t i>
40 std::bool_constant<(i < Node::degree())> checkChildIndex (Node
const& node, index_constant<i>)
42 static_assert(i < Node::degree(),
"Child index out of range");
46 template<
class NodePtr>
47 auto childStorageImpl (NodePtr&& nodePtr)
49 return std::forward<NodePtr>(nodePtr);
53 template<
class NodePtr,
class I0,
class... I>
54 decltype(
auto) childStorageImpl (NodePtr&& nodePtr, I0 i0, [[maybe_unused]] I... i)
56 auto valid = checkChildIndex(*nodePtr,i0);
58 return childStorageImpl(nodePtr->childStorage(i0),i...);
64 template<
class NodePtr,
class... Indices, std::size_t... i>
67 return childStorageImpl(std::forward<NodePtr>(nodePtr),
treePathEntry<i>(tp)...);
74 template<
typename Node,
typename... Indices>
77 static_assert(
sizeof...(Indices) > 0,
"childStorage() cannot be called with an empty list of child indices");
78 return Impl::childStorageImpl(&node,indices...);
81 template<
typename Node,
typename... Indices>
84 static_assert(
sizeof...(Indices) > 0,
"childStorage() cannot be called with an empty TreePath");
85 return Impl::childStorage(&node, treePath, std::index_sequence_for<Indices...>{});
96 using type = std::is_integral<T>;
100 template<std::
size_t i>
101 struct _is_flat_index<index_constant<i>>
103 using type = std::true_type;
127 constexpr typename std::enable_if<
131 _non_empty_tree_path (T)
137 constexpr typename std::enable_if<
141 _non_empty_tree_path (T t)
constexpr auto treePathEntry(const HybridTreePath< T... > &tp, index_constant< i >={})
Returns a copy of the i-th element of the HybridTreePath.
Definition treepath.hh:214
constexpr std::size_t treePathSize(const HybridTreePath< T... > &)
Returns the size (number of components) of the given HybridTreePath.
Definition treepath.hh:191
Dune::HybridMultiIndex< T... > HybridTreePath
A type for representing tree paths that supports both compile time and run time indices.
Definition treepath.hh:85
Definition accumulate_static.hh:17
Definition accumulate_static.hh:18
typename impl::_is_flat_index< std::decay_t< T > >::type is_flat_index
Type trait that determines whether T is a flat index in the context of child extraction.
Definition childextraction.hh:117
auto childStorage(Node &&node, Indices... indices)
Definition childextraction.hh:75
Definition typetraits.hh:150