6#ifndef DUNE_TYPETREE_TREEPATH_HH
7#define DUNE_TYPETREE_TREEPATH_HH
14#include <dune/common/documentation.hh>
15#include <dune/common/typetraits.hh>
16#include <dune/common/indices.hh>
17#include <dune/common/hybridutilities.hh>
18#include <dune/common/typelist.hh>
20#include <dune/typetree/hybridmultiindex.hh>
30 constexpr bool isHybridSizeT()
32 if constexpr (std::is_same_v<T, std::size_t>)
36 if constexpr (
requires { T::value; })
37 return std::is_same_v<T, std::integral_constant<std::size_t, T::value>>;
44 constexpr auto castToHybridSizeT(T t)
46 if constexpr (Dune::IsIntegralConstant<T>::value)
48 using VT =
typename T::value_type;
50 std::is_convertible_v<VT,std::size_t> &&
51 std::is_integral_v<VT> &&
53 "HybridTreePath indices must be convertible to std::size_t or std::integral_constant<std::size_t,v>");
54 return std::integral_constant<std::size_t, T::value>{};
57 std::is_convertible_v<T,std::size_t> &&
58 std::is_integral_v<T>,
59 "HybridTreePath indices must be convertible to std::size_t or std::integral_constant<std::size_t,v>");
61 "HybridTreePath indices must be convertible to std::size_t or std::integral_constant<std::size_t,v>");
62 return std::size_t(t);
72 namespace TreePathType {
73 enum Type { fullyStatic, dynamic };
85 template<
typename,std::
size_t>
91 template<
typename,std::
size_t>
109 template<
typename, std::size_t...>
121 template<
typename,
typename>
124 template<std::size_t... i>
125 [[deprecated(
"This function will be removed after Dune 2.11.")]]
126 void print_tree_path(std::ostream& os)
129 template<std::size_t k, std::size_t... i>
130 [[deprecated(
"This function will be removed after Dune 2.11.")]]
131 void print_tree_path(std::ostream& os)
134 print_tree_path<i...>(os);
151 template<
typename... T>
164 template<
typename... T>
165 requires (((std::is_integral_v<T> or Dune::IsIntegralConstant<T>::value) && ...))
182 template<
typename... T>
183 requires (((std::is_integral_v<T> or Dune::IsIntegralConstant<T>::value) && ...))
197 template<
typename... T>
198 requires (((std::is_integral_v<T> or Dune::IsIntegralConstant<T>::value) && ...))
199 [[nodiscard]]
constexpr auto treePath(
const T&... t)
206 template<
typename... T>
229 template<std::size_t i,
typename... T>
232 return tp[index_constant<i>{}];
253 template<std::size_t i,
typename... T>
254 [[deprecated(
"This function will be removed after Dune 2.11. Use operator[] instead.")]]
257 return tp[index_constant<i>{}];
266 using Dune::push_back;
267 using Dune::push_front;
268 using Dune::accumulate_back;
269 using Dune::accumulate_front;
272 using Dune::pop_front;
273 using Dune::pop_back;
275 inline namespace Literals {
282 template <
char... digits>
283 constexpr auto operator""_tp()
285 using namespace Dune::Indices::Literals;
292 template<std::size_t... i>
294 [[deprecated(
"This class will be removed after Dune 2.11. Use the size() member function instead.")]]
295 TreePathSize<HybridTreePath<index_constant<i>...> >
296 :
public index_constant<
sizeof...(i)>
300 template<std::size_t k, std::size_t... i>
302 [[deprecated(
"This class will be removed after Dune 2.11. Use the free push_back() function instead.")]]
303 TreePathPushBack<HybridTreePath<index_constant<i>...>,k>
305 typedef HybridTreePath<index_constant<i>...,index_constant<k>> type;
308 template<std::size_t k, std::size_t... i>
310 [[deprecated(
"This class will be removed after Dune 2.11. Use the free push_front() function instead.")]]
311 TreePathPushFront<HybridTreePath<index_constant<i>...>,k>
313 typedef HybridTreePath<index_constant<k>,index_constant<i>...> type;
316 template<std::
size_t k>
318 [[deprecated(
"This class will be removed after Dune 2.11. Use the back() member function instead.")]]
319 TreePathBack<HybridTreePath<index_constant<k>>>
320 :
public index_constant<k>
323 template<std::size_t j, std::size_t k, std::size_t... l>
325 [[deprecated(
"This class will be removed after Dune 2.11. Use the back() member function instead.")]]
326 TreePathBack<HybridTreePath<index_constant<j>,index_constant<k>,index_constant<l>...>>
327 :
public TreePathBack<HybridTreePath<index_constant<k>,index_constant<l>...>>
330 template<std::size_t k, std::size_t... i>
332 [[deprecated(
"This class will be removed after Dune 2.11. Use the front() member function instead.")]]
333 TreePathFront<HybridTreePath<index_constant<k>,index_constant<i>...>>
334 :
public index_constant<k>
337 template<std::size_t k, std::size_t... i>
339 [[deprecated(
"This class will be removed after Dune 2.11. Use the free pop_back() function instead.")]]
340 TreePathPopBack<HybridTreePath<index_constant<k>>,i...>
342 typedef HybridTreePath<index_constant<i>...> type;
345 template<std::size_t j,
350 [[deprecated(
"This class will be removed after Dune 2.11. Use the free pop_back() function instead.")]]
351 TreePathPopBack<HybridTreePath<index_constant<j>,index_constant<k>,index_constant<l>...>,i...>
352 :
public TreePathPopBack<HybridTreePath<index_constant<k>,index_constant<l>...>,i...,j>
355 template<std::size_t k, std::size_t... i>
357 [[deprecated(
"This class will be removed after Dune 2.11. Use the free pop_front() function instead.")]]
358 TreePathPopFront<HybridTreePath<index_constant<k>,index_constant<i>...> >
360 typedef HybridTreePath<index_constant<i>...> type;
363 template<std::size_t... i, std::size_t... k>
365 [[deprecated(
"This class will be removed after Dune 2.11. Use the free join() function instead.")]]
366 TreePathConcat<HybridTreePath<index_constant<i>...>,HybridTreePath<index_constant<k>...> >
368 typedef HybridTreePath<index_constant<i>...,index_constant<k>...> type;
371 template<std::size_t... i>
372 using StaticTreePath = HybridTreePath<Dune::index_constant<i>...>;
A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:81
constexpr auto treePathEntry(const HybridTreePath< T... > &tp, index_constant< i >={})
Returns a copy of the i-th element of the HybridTreePath.
Definition: treepath.hh:230
constexpr std::size_t treePathSize(const HybridTreePath< T... > &)
Returns the size (number of components) of the given HybridTreePath.
Definition: treepath.hh:207
constexpr auto makeTreePath(const T... t)
helper function to construct a new HybridTreePath from the given indices.
Definition: treepath.hh:166
constexpr auto hybridTreePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:184
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:255
constexpr auto treePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:199
Definition: treepath.hh:98
Definition: treepath.hh:122
Definition: treepath.hh:104
Definition: treepath.hh:110
Definition: treepath.hh:116
Definition: treepath.hh:86
Definition: treepath.hh:92
Definition: treepath.hh:80