A type for representing tree paths that supports both compile time and run time indices.
A HybridTreePath supports storing a combination of run time and compile time indices. This makes it possible to store the tree path to a tree node inside the tree node itself, even if the path contains one or more PowerNodes, where each child must have exactly the same type. At the same time, as much information as possible is kept accessible at compile time, allowing for more efficient algorithms.
- Note
- Internally all indices are stored as std::size_t or std::integral_constant<std::size_t,v>. The latter is the same as Dune::index_constant<v>. If indices of other integral or std::integral_constant types are passed as arguments, they are converted.
template<std::size_t i, typename... T>
| auto Dune::TypeTree::treePathEntry |
( |
const HybridTreePath< T... > & | tp, |
|
|
index_constant< i > | = {} ) |
|
nodiscardconstexpr |
Returns a copy of the i-th element of the HybridTreePath.
As HybridTreePath instances should not be mutated after their creation, this function returns a copy of the value. As values are either std::integral_constant or std::size_t, that's just as cheap as returning a reference.
The index for the entry can be passed either as a template parameter or as an index_constant:
using namespace Dune::Indices;
std::cout << treePathEntry<2>(tp) << std::endl;
constexpr auto treePathEntry(const HybridTreePath< T... > &tp, index_constant< i >={})
Returns a copy of the i-th element of the HybridTreePath.
Definition treepath.hh:214
constexpr auto hybridTreePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition treepath.hh:102
template<std::size_t i, typename... T>
| std::size_t Dune::TypeTree::treePathIndex |
( |
const HybridTreePath< T... > & | tp, |
|
|
index_constant< i > | = {} ) |
|
nodiscardconstexpr |
Returns the index value of the i-th element of the HybridTreePath.
This function always returns the actual index value, irrespective of whether the entry is a compile time index or a run time index.
- Deprecated
- The functions is deprecated. Use operator[] instead.
The index for the entry can be passed either as a template parameter or as an index_constant:
using namespace Dune::Indices;
std::cout << treePathIndex<2>(tp) << std::endl;
constexpr std::size_t treePathIndex(const HybridTreePath< T... > &tp, index_constant< i >={})
Returns the index value of the i-th element of the HybridTreePath.
Definition treepath.hh:239