dune-typetree  2.4-dev
Classes | Typedefs | Functions
Child Extraction
Collaboration diagram for Child Extraction:

Classes

struct  Dune::TypeTree::extract_child_type< Node, TreePath >
 Extract the type of the child of Node at position TreePath. More...
 

Typedefs

template<typename Node , std::size_t... indices>
using Dune::TypeTree::Child = typename impl::_Child< Node, indices...>::type
 Template alias for the type of a child node given by a list of child indices. More...
 
template<typename Node , typename TreePath >
using Dune::TypeTree::ChildForTreePath = typename impl::_ChildForTreePath< Node, TreePath >::type
 Template alias for the type of a child node given by a TreePath or a HybridTreePath type. More...
 
template<typename T >
using Dune::TypeTree::is_flat_index = typename impl::_is_flat_index< typename std::decay< T >::type >::type
 Type trait that determines whether T is a flat index in the context of child extraction. More...
 

Functions

template<typename Node , typename TreePath >
ImplementationDefined & Dune::TypeTree::extract_child (Node &node, Treepath tp)
 Extract the child of a node located at tp (non-const version). More...
 
template<typename Node , typename TreePath >
const ImplementationDefined & Dune::TypeTree::extract_child (const Node &node, Treepath tp)
 Extract the child of a node located at tp (const version). More...
 
template<typename Node , typename TreePath >
ImplementationDefined Dune::TypeTree::extract_child_storage (Node &node, Treepath tp)
 
template<typename Node , typename TreePath >
ImplementationDefined Dune::TypeTree::extract_child_storage (const Node &node, Treepath tp)
 
template<typename Node , typename... Indices>
ImplementationDefined Dune::TypeTree::child (Node &&node, Indices...indices)
 Extracts the child of a node given by a sequence of compile-time and run-time indices. More...
 
template<typename Node , std::size_t... Indices>
ImplementationDefined Dune::TypeTree::child (Node &&node, TreePath< Indices...> treePath)
 Extracts the child of a node given by a static TreePath object. More...
 
template<typename Node , typename... Indices>
ImplementationDefined Dune::TypeTree::child (Node &&node, HybridTreePath< Indices...> treePath)
 Extracts the child of a node given by a HybridTreePath object. More...
 

Detailed Description

Utility functions and metafunctions for extracting children from a TypeTree.

Typedef Documentation

template<typename Node , std::size_t... indices>
using Dune::TypeTree::Child = typedef typename impl::_Child<Node,indices...>::type

Template alias for the type of a child node given by a list of child indices.

This template alias is implemented in terms of the free-standing child() functions and uses those in combination with decltype() to extract the child type.

Template Parameters
NodeThe type of the parent node.
indicesA list of index values the describes the path to the wanted child.
template<typename Node , typename TreePath >
using Dune::TypeTree::ChildForTreePath = typedef typename impl::_ChildForTreePath<Node,TreePath>::type

Template alias for the type of a child node given by a TreePath or a HybridTreePath type.

This template alias is implemented in terms of the free-standing child() functions and uses those in combination with decltype() to extract the child type. It supports both TreePath and HybridTreePath.

Template Parameters
NodeThe type of the parent node.
TreePathThe type of a TreePath or a HybridTreePath that describes the path to the wanted child.
template<typename T >
using Dune::TypeTree::is_flat_index = typedef typename impl::_is_flat_index<typename std::decay<T>::type>::type

Type trait that determines whether T is a flat index in the context of child extraction.

Function Documentation

template<typename Node , typename... Indices>
ImplementationDefined Dune::TypeTree::child ( Node &&  node,
Indices...  indices 
)

Extracts the child of a node given by a sequence of compile-time and run-time indices.

Use this function to extract a (possibly indirect) child of a TypeTree node.

Example:

using namespace Dune::TypeTree::Indices; // for compile-time indices
auto&& c = child(node,_4,2,_0,1);

returns the second child of the first child of the third child of the fifth child of node, where some child lookups were done using a compile-time index and some using a run-time index.

Parameters
nodeThe node from which to extract the child.
indices...A list of indices that describes the path into the tree to the wanted child. These parameters can be a combination of run time indices (for tree nodes that allow accessing their children using run time information, like PowerNode) and instances of index_constant, which work for all types of inner nodes.
Returns
A reference to the child, its cv-qualification depends on the passed-in node.

References Dune::TypeTree::child().

Referenced by Dune::TypeTree::child().

template<typename Node , std::size_t... Indices>
ImplementationDefined Dune::TypeTree::child ( Node &&  node,
TreePath< Indices...>  treePath 
)

Extracts the child of a node given by a static TreePath object.

Use this function to extract a (possibly indirect) child of a TypeTree node.

Example:

auto&& c = child(node,tp);

returns the second child of the first child of the third child of the fifth child of node.

Parameters
nodeThe node from which to extract the child.
treePathA TreePath object that describes the path into the tree to the wanted child.
Returns
A reference to the child, its cv-qualification depends on the passed-in node.

References Dune::TypeTree::child().

template<typename Node , typename... Indices>
ImplementationDefined Dune::TypeTree::child ( Node &&  node,
HybridTreePath< Indices...>  treePath 
)

Extracts the child of a node given by a HybridTreePath object.

Use this function to extract a (possibly indirect) child of a TypeTree node.

Example:

using namespace Dune::TypeTree::Indices; // for compile-time indices
auto&& c = child(node,tp);

returns the second child of the first child of the third child of the fifth child of node, where some child lookups were done using a compile-time index and some using a run-time index.

Parameters
nodeThe node from which to extract the child.
tree{athA HybridTreePath that describes the path into the tree to the wanted child. This tree path object can be a combination of run time indices (for tree nodes that allow accessing their children using run time information, like PowerNode) and instances of index_constant, which work for all types of inner nodes.
Returns
A reference to the child, its cv-qualification depends on the passed-in node.

Referenced by Dune::TypeTree::child().

template<typename Node , typename TreePath >
ImplementationDefined& Dune::TypeTree::extract_child ( Node &  node,
Treepath  tp 
)

Extract the child of a node located at tp (non-const version).

Use this function to extract a (possibly indirect) child of a TypeTree node.

Example:

extract_child(node,Dune::TypeTree::TreePath<2,3,0>())

returns the first child of the fourth child of the third child of node.

See also
Use extract_child_type to determine the type of the return value.
Parameters
nodeThe node from which to extract the child.
tpThe path into the tree leading to the child. Note that the actual instance is not used at all by this function, only the type of the parameter.
Template Parameters
TreePathA TreePath instantiation which statically encodes the path to the child.
Returns
A reference to the child.
Deprecated:
extract_child is deprecated and will be removed after TypeTree 2.4, use the freestanding function child() or the enhanced child() methods on the tree nodes instead.
template<typename Node , typename TreePath >
const ImplementationDefined& Dune::TypeTree::extract_child ( const Node &  node,
Treepath  tp 
)

Extract the child of a node located at tp (const version).

Use this function to extract a (possibly indirect) child of a TypeTree node.

Example:

extract_child(node,Dune::TypeTree::TreePath<2,3,0>())

returns the first child of the fourth child of the third child of node.

See also
Use extract_child_type to determine the type of the return value.
Parameters
nodeThe node from which to extract the child.
tpThe path into the tree leading to the child. Note that the actual instance is not used at all by this function, only the type of the parameter.
Template Parameters
TreePathA TreePath instantiation which statically encodes the path to the child.
Returns
A reference to the child.
Deprecated:
extract_child is deprecated and will be removed after TypeTree 2.4, use the freestanding function child() or the enhanced child() methods on the tree nodes instead.
template<typename Node , typename TreePath >
ImplementationDefined Dune::TypeTree::extract_child_storage ( Node &  node,
Treepath  tp 
)

Extract the storage for the child of a node located at tp (non-const version). Use this function to extract the storage (usually a shared_ptr) of a (possibly indirect) child of a TypeTree node.

Example:

extract_child_storage(node,Dune::TypeTree::TreePath<2,3,0>())

returns the first child of the fourth child of the third child of node.

See also
Use extract_child_type to determine the type of the return value.
Parameters
nodeThe node from which to extract the child.
tpThe path into the tree leading to the child. Note that the actual instance is not used at all by this function, only the type of the parameter.
Template Parameters
TreePathA TreePath instantiation which statically encodes the path to the child.
Returns
A reference to the child.
template<typename Node , typename TreePath >
ImplementationDefined Dune::TypeTree::extract_child_storage ( const Node &  node,
Treepath  tp 
)

Extract the storage for the child of a node located at tp (const version). Use this function to extract the const storage (usually a shared_ptr) of a (possibly indirect) child of a TypeTree node.

Example:

extract_child_storage(node,Dune::TypeTree::TreePath<2,3,0>())

returns the first child of the foruth child of the third child of node.

See also
Use extract_child_type to determine the type of the return value.
Parameters
nodeThe node from which to extract the child.
tpThe path into the tree leading to the child. Note that the actual instance is not used at all by this function, only the type of the parameter.
Template Parameters
TreePathA TreePath instantiation which statically encodes the path to the child.
Returns
A reference to the child.