Dune Core Modules (unstable)

treepath.hh
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
17#include <dune/common/hybridmultiindex.hh>
18
19
20namespace 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;
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
A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:81
Documentation related stuff.
constexpr auto treePath(const T &... t)
Constructs a new TreePath from the given indices.
Definition: treepath.hh:55
constexpr auto join(const HybridMultiIndex< Head... > &head, const Other &... tail)
Join two hybrid multi-indices into one.
Definition: hybridmultiindex.hh:355
constexpr auto reverse(const HybridMultiIndex< T... > &tp)
Reverses the order of the elements in the multi-index.
Definition: hybridmultiindex.hh:361
constexpr auto pop_back(const HybridMultiIndex< T... > &tp)
Removes last index on a HybridMultiIndex.
Definition: hybridmultiindex.hh:387
constexpr auto pop_front(const HybridMultiIndex< T... > &tp)
Removes first index on a HybridMultiIndex.
Definition: hybridmultiindex.hh:374
constexpr auto accumulate_back(const HybridMultiIndex< T... > &tp, I i)
Hybrid utility that accumulates to the back of a multi-index.
Definition: hybridmultiindex.hh:328
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 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
constexpr auto accumulate_front(const HybridMultiIndex< T... > &tp, I i)
Hybrid utility that accumulates to the front of a multi-index.
Definition: hybridmultiindex.hh:348
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
constexpr auto front(const HybridMultiIndex< T... > &tp) -> decltype(tp.front())
Returns a copy of the first element of the HybridMultiIndex.
Definition: hybridmultiindex.hh:238
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:384
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Jan 9, 23:34, 2026)