Dune TypeTree (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: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-PDELab-exception
5
6#ifndef DUNE_TYPETREE_TREEPATH_HH
7#define DUNE_TYPETREE_TREEPATH_HH
8
9#include <cstddef>
10#include <cassert>
11#include <iostream>
12#include <type_traits>
13
14#include <dune/common/documentation.hh>
15#include <dune/common/typetraits.hh>
16#include <dune/common/indices.hh>
17
18#include <dune/common/typetree/treepath.hh>
19
20
21namespace Dune {
22 namespace TypeTree {
23
27
29
42 template<typename... T>
43 using HybridTreePath = Dune::HybridMultiIndex<T...>;
44
46
58 template<typename... T>
59 requires (((std::is_integral_v<T> or Dune::IsIntegralConstant<T>::value) && ...))
60 [[nodiscard]] constexpr auto hybridTreePath(const T&... t)
61 {
62 return HybridMultiIndex(t...);
63 }
64
65 namespace TreePathType {
66 enum Type { fullyStatic, dynamic };
67 }
68
70
79 template<typename... T>
80 requires (((std::is_integral_v<T> or Dune::IsIntegralConstant<T>::value) && ...))
81 [[nodiscard]] constexpr auto makeTreePath(const T... t)
82 {
83 return HybridMultiIndex(t...);
84 }
85
87 template<typename... T>
88 [[nodiscard]] constexpr std::size_t treePathSize(const HybridTreePath<T...>&)
89 {
90 return sizeof...(T);
91 }
92
94
110 template<std::size_t i, typename... T>
111 [[nodiscard]] constexpr auto treePathEntry(const HybridTreePath<T...>& tp, index_constant<i> = {})
112 {
113 return tp[index_constant<i>{}];
114 }
115
116 template<std::size_t... i>
117 using StaticTreePath = HybridTreePath<Dune::index_constant<i>...>;
118
120
121 } // namespace TypeTree
122} //namespace Dune
123
124
125
126#endif // DUNE_TYPETREE_TREEPATH_HH
constexpr auto treePathEntry(const HybridTreePath< T... > &tp, index_constant< i >={})
Returns a copy of the i-th element of the HybridTreePath.
Definition: treepath.hh:111
constexpr std::size_t treePathSize(const HybridTreePath< T... > &)
Returns the size (number of components) of the given HybridTreePath.
Definition: treepath.hh:88
constexpr auto makeTreePath(const T... t)
helper function to construct a new HybridTreePath from the given indices.
Definition: treepath.hh:81
constexpr auto hybridTreePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:60
Dune::HybridMultiIndex< T... > HybridTreePath
A type for representing tree paths that supports both compile time and run time indices.
Definition: treepath.hh:43
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 16, 22:33, 2026)