dune-common  2.11
treepath.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
5 
6 #ifndef DUNE_COMMON_TYPETREE_TREEPATH_HH
7 #define DUNE_COMMON_TYPETREE_TREEPATH_HH
8 
9 #include <cstddef>
10 #include <cassert>
11 #include <type_traits>
12 
15 #include <dune/common/indices.hh>
16 
18 
19 
20 namespace Dune::TypeTree {
21 
25 
27 
42  template<typename... T>
44 
46 
53  template<typename... T>
54  requires (((std::is_integral_v<T> or Dune::IsIntegralConstant<T>::value) && ...))
55  [[nodiscard]] constexpr auto treePath(const T&... t)
56  {
57  return HybridMultiIndex(t...);
58  }
59 
60  // Pull in the free utility function for HybridMultiIndex/TreePath
61  // We cannot add forwarding functions of the same name here, since this
62  // leads to ambiguous overloads.
63  // Unfortunately doxygen ignores documentation for using statements.
64  using Dune::back;
65  using Dune::front;
66  using Dune::push_back;
67  using Dune::push_front;
68  using Dune::accumulate_back;
69  using Dune::accumulate_front;
70  using Dune::join;
71  using Dune::reverse;
72  using Dune::pop_front;
73  using Dune::pop_back;
74 
75  inline namespace Literals {
76 
78 
82  template <char... digits>
83  constexpr auto operator""_tp()
84  {
85  using namespace Dune::Indices::Literals;
86  return treePath(operator""_ic<digits...>());
87  }
88 
89  } // end namespace Literals
90 
91 
93 
94 } //namespace Dune::TypeTree
95 
96 
97 
98 #endif // DUNE_TYPETREE_TREEPATH_HH
constexpr auto back(const HybridMultiIndex< T... > &tp) -> decltype(tp.back())
Returns a copy of the last element of the HybridMultiIndex.
Definition: hybridmultiindex.hh:225
constexpr auto reverse(const HybridMultiIndex< T... > &tp)
Reverses the order of the elements in the multi-index.
Definition: hybridmultiindex.hh:361
HybridMultiIndex(std::tuple< I... >) -> HybridMultiIndex< I... >
constexpr auto front(const HybridMultiIndex< T... > &tp) -> decltype(tp.front())
Returns a copy of the first element of the HybridMultiIndex.
Definition: hybridmultiindex.hh:238
constexpr HybridMultiIndex< std::size_t, T... > push_front(const HybridMultiIndex< T... > &tp, std::size_t i)
Prepends a run time index to a HybridMultiIndex.
Definition: hybridmultiindex.hh:284
Definition: childaccess.hh:23
Definition: indices.hh:130
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:383
requires(((std::is_integral_v< T > or Dune::IsIntegralConstant< T >::value) &&...)) const expr auto treePath(const T &... t)
Constructs a new TreePath from the given indices.
Definition: treepath.hh:54
constexpr auto join(const HybridMultiIndex< Head... > &head, const Other &... tail)
Join two hybrid multi-indices into one.
Definition: hybridmultiindex.hh:355
A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:80
Documentation related stuff.
Traits for type conversions and type information.
constexpr HybridMultiIndex< T..., std::size_t > push_back(const HybridMultiIndex< T... > &tp, std::size_t i)
Appends a run time index to a HybridMultiIndex.
Definition: hybridmultiindex.hh:249