4 #ifndef DUNE_TYPETREE_TREEPATH_HH 5 #define DUNE_TYPETREE_TREEPATH_HH 10 #include <dune/common/documentation.hh> 11 #include <dune/common/typetraits.hh> 25 namespace TreePathType {
29 template<std::size_t... i>
44 template<std::size_t... i>
50 template<std::size_t... i>
56 template<
typename,std::
size_t>
59 template<std::size_t k, std::size_t... i>
65 template<
typename,std::
size_t>
68 template<std::size_t k, std::size_t... i>
78 template<std::
size_t k>
88 template<std::size_t j, std::size_t k, std::size_t... l>
96 template<std::size_t k, std::size_t... i>
101 template<
typename, std::size_t...>
104 template<std::size_t k, std::size_t... i>
110 template<std::size_t j,
121 template<std::size_t k, std::size_t... i>
127 template<
typename,
typename>
130 template<std::size_t... i, std::size_t... k>
136 template<std::size_t... i>
140 template<std::size_t k, std::size_t... i>
147 template<std::size_t... i>
165 return _stack.size();
177 return _stack.back();
183 return _stack.front();
189 for (std::size_t i = 0; i < tp.
size(); ++i)
211 #ifndef DOXYGEN // DynamicTreePath subclasses are implementation details and never exposed to the user 221 class MutableDynamicTreePath
239 void set_back(std::size_t v)
251 MutableDynamicTreePath(Stack& stack)
262 template<std::
size_t treeDepth>
263 class MakeableDynamicTreePath
265 ,
public MutableDynamicTreePath
270 MutableDynamicTreePath mutablePath()
272 return static_cast<MutableDynamicTreePath&
>(*this);
275 MakeableDynamicTreePath()
284 template<TreePathType::Type tpType>
285 struct TreePathFactory;
291 template<
typename Tree>
300 struct TreePathFactory<TreePathType::
dynamic>
302 template<
typename Tree>
303 static MakeableDynamicTreePath<TreeInfo<Tree>::depth> create(
const Tree& tree)
305 return MakeableDynamicTreePath<TreeInfo<Tree>::depth>();
321 template<
typename... T>
343 template<
typename... U,
typename std::enable_if<(
sizeof...(T) > 0 &&
sizeof...(U) ==
sizeof...(T)),
bool>::type =
true>
359 using Data = std::tuple<T...>;
372 template<
typename... T>
380 template<
typename... T>
403 template<std::size_t i,
typename... T>
405 ->
typename std::decay<decltype(std::get<i>(tp._data))>::type
407 return std::get<i>(tp._data);
426 template<std::size_t i,
typename... T>
429 return std::get<i>(tp._data);
438 template<
typename... T,
typename std::enable_if<(
sizeof...(T) > 0),
bool>::type =
true>
440 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 && __GNUC_MINOR__ < 8 450 template<
typename... T,
typename std::enable_if<(
sizeof...(T) > 0),
bool>::type =
true>
462 template<
typename... T>
464 -> decltype(treePathEntry<0>(tp))
466 return treePathEntry<0>(tp);
470 template<
typename... T>
473 return treePathEntry<0>(tp);
480 template<
typename... T>
483 return HybridTreePath<T...,std::size_t>(std::tuple_cat(tp._data,std::make_tuple(i)));
501 template<std::size_t i,
typename... T>
511 template<
typename... T>
514 return HybridTreePath<std::size_t,T...>(std::tuple_cat(std::make_tuple(element),tp._data));
532 template<std::size_t i,
typename... T>
543 template<std::size_t i,
typename... T>
544 typename std::enable_if<
551 template<std::size_t i,
typename... T>
552 typename std::enable_if<
566 template<
typename... T>
569 os <<
"HybridTreePath< ";
580 #endif // DUNE_TYPETREE_TREEPATH_HH TreePath ViewType
Definition: treepath.hh:36
HybridTreePath< T..., std::size_t > push_back(const HybridTreePath< T... > &tp, std::size_t i)
Appends a run time index to a HybridTreePath.
Definition: treepath.hh:481
Definition: treepath.hh:42
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: utility.hh:312
std::size_t front() const
Get the first index value.
Definition: treepath.hh:181
constexpr HybridTreePath(std::tuple< T... > t)
Constructor from a std::tuple
Definition: treepath.hh:338
constexpr HybridTreePath< T... > hybridTreePath(const T &...t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:373
A hybrid version of TreePath that supports both compile time and run time indices.
Definition: treepath.hh:322
std::ostream & operator<<(std::ostream &os, const TreePath< i... > &tp)
Definition: treepath.hh:148
TreePath< i..., k... > type
Definition: treepath.hh:133
TreePath< i..., k > type
Definition: treepath.hh:62
Definition: treepath.hh:26
Definition: treepath.hh:57
std::size_t element(std::size_t pos) const
Get the index value at position pos.
Definition: treepath.hh:169
Definition: treepath.hh:75
std::size_t back() const
Get the last index value.
Definition: treepath.hh:175
std::size_t size() const
Get the size (length) of this path.
Definition: treepath.hh:163
TreePath view()
Definition: treepath.hh:37
Definition: treepath.hh:26
Definition: treepath.hh:128
TreePath< i... > type
Definition: treepath.hh:107
A TreePath that stores the path of a node as runtime information.
Definition: treepath.hh:157
auto back(const HybridTreePath< T... > &tp) -> decltype(treePathEntry< treePathSize(tp)-1 >(tp))
Returns a copy of the last element of the HybridTreePath.
Definition: treepath.hh:439
static constexpr index_sequence enumerate()
Returns an index_sequence for enumerating the components of this HybridTreePath.
Definition: treepath.hh:349
Type
Definition: treepath.hh:26
std::size_t frontIndex(const HybridTreePath< T... > &tp)
Returns the index value of the first element of the HybridTreePath.
Definition: treepath.hh:471
Definition: treepath.hh:30
Definition: treepath.hh:66
void print_tree_path(std::ostream &os)
Definition: treepath.hh:137
constexpr std::size_t treePathSize(const TreePath< i... > &)
Returns the size (number of components) of the given TreePath.
Definition: treepath.hh:51
Definition: fixedcapacitystack.hh:19
friend std::ostream & operator<<(std::ostream &os, const DynamicTreePath &tp)
Definition: treepath.hh:186
TreePath< k, i... > type
Definition: treepath.hh:71
Definition: treepath.hh:102
Std::index_sequence_for< T... > index_sequence
An index_sequence for the entries in this HybridTreePath.
Definition: treepath.hh:328
Definition: treepath.hh:94
TreePath< i... > type
Definition: treepath.hh:124
TreePath mutablePath()
Definition: treepath.hh:38
auto treePathEntry(const HybridTreePath< T... > &tp, index_constant< i >={}) -> typename std::decay< decltype(std::get< i >(tp._data))>::type
Returns a copy of the i-th element of the HybridTreePath.
Definition: treepath.hh:404
make_index_sequence< impl::_get_pack_length< T... >{}> index_sequence_for
Create an index_sequence for the pack T..., i.e. [0,sizeof...(T)].
Definition: utility.hh:298
Definition: accumulate_static.hh:12
constexpr HybridTreePath()
Default constructor.
Definition: treepath.hh:331
Definition: treepath.hh:119
HybridTreePath< std::size_t, T... > push_front(const HybridTreePath< T... > &tp, std::size_t element)
Prepends a run time index to a HybridTreePath.
Definition: treepath.hh:512
auto front(const HybridTreePath< T... > &tp) -> decltype(treePathEntry< 0 >(tp))
Returns a copy of the first element of the HybridTreePath.
Definition: treepath.hh:463
Definition: treepath.hh:26
constexpr HybridTreePath(U...t)
Constructor from arguments.
Definition: treepath.hh:344
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:427
Definition: fixedcapacitystack.hh:119
std::size_t backIndex(const HybridTreePath< T... > &tp)
Returns the index value of the last element of the HybridTreePath.
Definition: treepath.hh:451