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;
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
A hybrid multi-index class that supports both compile time and run time indices.
Definition: hybridmultiindex.hh:85
Documentation related stuff.
constexpr auto treePath(const T &... t)
Constructs a new TreePath from the given indices.
Definition: treepath.hh:55
constexpr std::integer_sequence< T, II..., T(IN)> push_back(std::integer_sequence< T, II... >, std::integral_constant< T, IN >={})
Append an index IN to the back of the sequence.
Definition: integersequence.hh:69
constexpr std::integer_sequence< T, T(I0), II... > push_front(std::integer_sequence< T, II... >, std::integral_constant< T, I0 >={})
Append an index I0 to the front of the sequence.
Definition: integersequence.hh:64
constexpr std::integral_constant< T, I0 > front(std::integer_sequence< T, I0, II... >)
Return the first entry of the sequence.
Definition: integersequence.hh:39
constexpr auto back(std::integer_sequence< T, II... > seq)
Return the last entry of the sequence.
Definition: integersequence.hh:44
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 (Jun 2, 23:00, 2026)