4 #ifndef DUNE_TYPETREE_TREECONTAINER_HH
5 #define DUNE_TYPETREE_TREECONTAINER_HH
12 #include <dune/common/indices.hh>
13 #include <dune/common/tuplevector.hh>
33 template<
class LeafToValue>
46 leafToValue_(leafToValue)
50 std::enable_if_t<Node::isLeaf, int> = 0>
53 return leafToValue_(node);
57 std::enable_if_t<Node::isPower, int> = 0>
60 using TransformedChild = decltype((*
this)(node.child(0)));
61 return std::array<TransformedChild, Node::degree()>();
65 std::enable_if_t<Node::isComposite, int> = 0>
68 return Dune::unpackIntegerSequence([&](
auto... indices) {
69 return Dune::makeTupleVector((*
this)(node.child(indices))...);
70 }, std::make_index_sequence<Node::degree()>());
74 LeafToValue leafToValue_;
81 template<
class Container>
85 static constexpr decltype(
auto) accessByTreePath(C&& container,
const HybridTreePath<>& path)
90 template<
class C,
class... T>
91 static constexpr decltype(
auto) accessByTreePath(C&& container,
const HybridTreePath<T...>& path)
93 auto head = path[Dune::Indices::_0];
94 auto tailPath = Dune::unpackIntegerSequence([&](
auto... i){
96 }, std::make_index_sequence<
sizeof...(T)-1>());
97 return accessByTreePath(container[head], tailPath);
106 container_(std::move(container))
110 container_(std::move(other.container_))
116 return accessByTreePath(container_, path);
122 return accessByTreePath(container_, path);
136 Container container_;
139 template<
class Container>
152 template<
template<
class Node>
class LeafToValue>
158 return LeafToValue<Node>{};
183 template<
class Tree,
class LeafToValue>
186 auto f = std::ref(leafToValue);
206 template<
class Value,
class Tree>
215 template<
class Value,
class Tree>
221 template<
template<
class Node>
class LeafToValue,
class Tree>
222 using TreeContainer = std::decay_t<decltype(makeTreeContainer(std::declval<const Tree&>(), std::declval<Detail::LeafToDefaultConstructibleValue<LeafToValue>>()))>;
229 #endif // DUNE_TYPETREE_TREECONTAINER_HH