4 #ifndef DUNE_TYPETREE_COMPOSITENODE_HH
5 #define DUNE_TYPETREE_COMPOSITENODE_HH
24 template<
typename... Children>
34 typedef std::tuple<std::shared_ptr<Children>... >
NodeStorage;
49 [[deprecated(
"Will be removed after release 2.9. Use degree()")]]
50 static const std::size_t
CHILDREN =
sizeof...(Children);
54 return std::integral_constant<std::size_t,
sizeof...(Children)>{};
58 template<std::
size_t k>
61 static_assert((k <
degree()),
"child index out of range");
64 typedef typename std::tuple_element<k,ChildTypes>::type
Type;
67 typedef typename std::tuple_element<k,ChildTypes>::type
type;
77 template<std::
size_t k>
80 return *std::get<k>(_children);
87 template<std::
size_t k>
90 return *std::get<k>(_children);
97 template<std::
size_t k>
100 return std::get<k>(_children);
107 template<std::
size_t k>
110 return std::get<k>(_children);
114 template<std::
size_t k>
117 std::get<k>(_children) = stackobject_to_shared_ptr(
child);
121 template<std::
size_t k>
124 std::get<k>(_children) = convert_arg(std::move(
child));
128 template<std::
size_t k>
131 std::get<k>(_children) = std::move(
child);
167 template<
typename... Indices>
168 ImplementationDefined&
child (Indices... indices)
170 template<
typename I0,
typename... I,
172 decltype(
auto)
child (I0 i0, I... i)
175 static_assert(
sizeof...(I) > 0 || impl::_non_empty_tree_path(I0{}),
176 "You cannot use the member function child() with an empty TreePath, use the freestanding version child(node,treePath) instead."
187 template<
typename... Indices>
188 const ImplementationDefined&
child (Indices... indices)
190 template<
typename I0,
typename... I,
192 decltype(
auto)
child (I0 i0, I... i) const
195 static_assert(
sizeof...(I) > 0 || impl::_non_empty_tree_path(I0{}),
196 "You cannot use the member function child() with an empty TreePath, use the freestanding version child(node,treePath) instead."
220 template<
typename... Args,
typename =
typename std::enable_if<(
sizeof...(Args) ==
degree())>::type>
222 : _children(convert_arg(std::forward<Args>(args))...)
227 : _children(std::move(children)...)
232 : _children(children)
ImplementationDefined child(Node &&node, Indices... indices)
Extracts the child of a node given by a sequence of compile-time and run-time indices.
Definition: childextraction.hh:126
Definition: accumulate_static.hh:13
Type
Definition: treepath.hh:30
Base class for composite nodes based on variadic templates.
Definition: compositenode.hh:26
const NodeStorage & nodeStorage() const
Definition: compositenode.hh:134
static const bool isLeaf
Mark this class as non leaf in the dune-typetree.
Definition: compositenode.hh:40
static const bool isComposite
Mark this class as a composite in the dune-typetree.
Definition: compositenode.hh:46
static const std::size_t CHILDREN
The number of children.
Definition: compositenode.hh:50
CompositeNode()
Default constructor.
Definition: compositenode.hh:216
CompositeNodeTag NodeTag
The type tag that describes a CompositeNode.
Definition: compositenode.hh:31
void setChild(typename Child< k >::Type &child, index_constant< k >={})
Sets the k-th child to the passed-in value.
Definition: compositenode.hh:115
const Child< k >::Type & child(index_constant< k >={}) const
Returns the k-th child (const version).
Definition: compositenode.hh:88
void setChild(typename Child< k >::Type &&child, index_constant< k >={})
Store the passed value in k-th child.
Definition: compositenode.hh:122
std::shared_ptr< const typename Child< k >::Type > childStorage(index_constant< k >={}) const
Returns the storage of the k-th child (const version).
Definition: compositenode.hh:108
static constexpr auto degree()
Definition: compositenode.hh:52
CompositeNode(std::shared_ptr< Children >... children)
Initialize the CompositeNode with copies of the passed in Storage objects.
Definition: compositenode.hh:226
std::tuple< Children... > ChildTypes
A tuple storing the types of all children.
Definition: compositenode.hh:37
void setChild(std::shared_ptr< typename Child< k >::Type > child, index_constant< k >={})
Sets the storage of the k-th child to the passed-in value.
Definition: compositenode.hh:129
Child< k >::Type & child(index_constant< k >={})
Returns the k-th child.
Definition: compositenode.hh:78
static const bool isPower
Mark this class as a non power in the dune-typetree.
Definition: compositenode.hh:43
const ImplementationDefined & child(Indices... indices)
Returns the child given by the list of indices.
Definition: compositenode.hh:188
std::shared_ptr< typename Child< k >::Type > childStorage(index_constant< k >={})
Returns the storage of the k-th child.
Definition: compositenode.hh:98
ImplementationDefined & child(Indices... indices)
Returns the child given by the list of indices.
Definition: compositenode.hh:168
CompositeNode(const NodeStorage &children)
Initialize the CompositeNode with a copy of the passed-in storage type.
Definition: compositenode.hh:231
std::tuple< std::shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: compositenode.hh:34
Access to the type and storage type of the i-th child.
Definition: compositenode.hh:59
std::tuple_element< k, ChildTypes >::type Type
The type of the child.
Definition: compositenode.hh:61
std::tuple_element< k, ChildTypes >::type type
The type of the child.
Definition: compositenode.hh:67
Tag designating a composite node.
Definition: nodetags.hh:25
Check if type represents a tree path.
Definition: typetraits.hh:182