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>>()))>;
auto makeTreeContainer(const Tree &tree, LeafToValue &&leafToValue)
Create container havin the same structure as the given tree.
Definition: treecontainer.hh:184
std::decay_t< decltype(makeTreeContainer< Value >(std::declval< const Tree & >()))> UniformTreeContainer
Alias to container type generated by makeTreeContainer for given tree type and uniform value type.
Definition: treecontainer.hh:216
std::decay_t< decltype(makeTreeContainer(std::declval< const Tree & >(), std::declval< Detail::LeafToDefaultConstructibleValue< LeafToValue > >()))> TreeContainer
Alias to container type generated by makeTreeContainer for give tree type and when using LeafToValue ...
Definition: treecontainer.hh:222
constexpr HybridTreePath< T... > treePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:188
Definition: accumulate_static.hh:13
auto makeTreeContainerVectorBackend(Container &&container)
Definition: treecontainer.hh:140
Definition: treecontainer.hh:35
ContainerFactory(LeafToValue leafToValue)
Create ContainerFactory.
Definition: treecontainer.hh:45
auto operator()(const Node &node)
Definition: treecontainer.hh:51
Definition: treecontainer.hh:83
Container & data()
Definition: treecontainer.hh:130
TreeContainerVectorBackend()
Definition: treecontainer.hh:101
TreeContainerVectorBackend(Container &&container)
Definition: treecontainer.hh:105
TreeContainerVectorBackend(TreeContainerVectorBackend &&other)
Definition: treecontainer.hh:109
const Container & data() const
Definition: treecontainer.hh:125
Definition: treecontainer.hh:154
auto operator()(const Node &node) const
Definition: treecontainer.hh:156
A hybrid version of TreePath that supports both compile time and run time indices.
Definition: treepath.hh:79