4 #ifndef DUNE_TYPETREE_VARIADICCOMPOSITENODE_HH
5 #define DUNE_TYPETREE_VARIADICCOMPOSITENODE_HH
7 #if !(HAVE_VARIADIC_TEMPLATES || DOXYGEN || HEADERCHECK)
8 #error The class VariadicCompositeNode requires compiler support for variadic templates, which your compiler lacks.
11 #if (HAVE_VARIADIC_TEMPLATES || DOXYGEN)
13 #include <dune/common/tuples.hh>
14 #include <dune/common/shared_ptr.hh>
15 #include <dune/common/static_assert.hh>
25 template<
typename... Children>
51 static const std::size_t
CHILDREN =
sizeof...(Children);
54 template<std::
size_t k>
60 typedef typename tuple_element<k,ChildTypes>::type
Type;
63 typedef typename tuple_element<k,ChildTypes>::type
type;
66 typedef typename tuple_element<k,NodeStorage>::type
Storage;
69 typedef shared_ptr<const typename tuple_element<k,ChildTypes>::type>
ConstStorage;
79 template<std::
size_t k>
82 return *get<k>(_children);
89 template<std::
size_t k>
92 return *get<k>(_children);
99 template<std::
size_t k>
102 return get<k>(_children);
112 template<std::
size_t k>
115 return get<k>(_children);
119 template<std::
size_t k>
122 get<k>(_children) = stackobject_to_shared_ptr(child);
126 template<std::
size_t k>
129 get<k>(_children) = child;
155 #if HAVE_RVALUE_REFERENCES && HAVE_VARIADIC_CONSTRUCTOR_SFINAE
156 template<
typename... Args,
typename =
typename enable_if<(
sizeof...(Args) ==
CHILDREN)>::type>
159 : _children(convert_arg(std::forward<Args>(args))...)
165 : _children(convert_arg(children)...)
172 : _children(children...)
177 : _children(children)
191 #endif // (HAVE_VARIADIC_TEMPLATES || DOXYGEN)
193 #endif // DUNE_TYPETREE_VARIADICCOMPOSITENODE_HH
tuple_element< k, ChildTypes >::type type
The type of the child.
Definition: variadiccompositenode.hh:63
const NodeStorage & nodeStorage() const
Definition: variadiccompositenode.hh:132
VariadicCompositeNodeTag NodeTag
The type tag that describes a VariadicCompositeNode.
Definition: variadiccompositenode.hh:33
static const std::size_t CHILDREN
The number of children.
Definition: variadiccompositenode.hh:51
shared_ptr< const typename tuple_element< k, ChildTypes >::type > ConstStorage
The const storage type of the child.
Definition: variadiccompositenode.hh:69
void setChild(typename Child< k >::Type &child)
Sets the i-th child to the passed-in value.
Definition: variadiccompositenode.hh:120
Child< k >::Storage childStorage()
Returns the storage of the i-th child.
Definition: variadiccompositenode.hh:100
tuple< shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: variadiccompositenode.hh:36
static const bool isPower
Mark this class as a non power in the dune-typetree.
Definition: variadiccompositenode.hh:45
void setChild(typename Child< k >::Storage child)
Sets the storage of the i-th child to the passed-in value.
Definition: variadiccompositenode.hh:127
Child< k >::ConstStorage childStorage() const
Returns the storage of the i-th child (const version).
Definition: variadiccompositenode.hh:113
Child< k >::Type & child()
Returns the i-th child.
Definition: variadiccompositenode.hh:80
Tag designating a composite node that is based on variadic templates.
Definition: nodetags.hh:25
static const bool isComposite
Mark this class as a composite in the dune-typetree.
Definition: variadiccompositenode.hh:48
VariadicCompositeNode()
Default constructor.
Definition: variadiccompositenode.hh:152
tuple_element< k, NodeStorage >::type Storage
The storage type of the child.
Definition: variadiccompositenode.hh:66
VariadicCompositeNode(const NodeStorage &children)
Initialize the VariadicCompositeNode with a copy of the passed-in storage type.
Definition: variadiccompositenode.hh:176
static const bool isLeaf
Mark this class as non leaf in the dune-typetree.
Definition: variadiccompositenode.hh:42
Access to the type and storage type of the i-th child.
Definition: variadiccompositenode.hh:55
Base class for composite nodes based on variadic templates.
Definition: variadiccompositenode.hh:27
tuple< Children...> ChildTypes
A tuple storing the types of all children.
Definition: variadiccompositenode.hh:39
VariadicCompositeNode(Children &...children)
Definition: variadiccompositenode.hh:164
VariadicCompositeNode(shared_ptr< Children >...children)
Initialize the VariadicCompositeNode with copies of the passed in Storage objects.
Definition: variadiccompositenode.hh:171
tuple_element< k, ChildTypes >::type Type
The type of the child.
Definition: variadiccompositenode.hh:60
dune_static_assert((k< CHILDREN),"child index out of range")
const Child< k >::Type & child() const
Returns the i-th child (const version).
Definition: variadiccompositenode.hh:90