Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
typetreefallback.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUFEM_TYPETREEFALLBACK_HH
8#define DUNE_FUFEM_TYPETREEFALLBACK_HH
9
17#include <concepts>
18#include <type_traits>
19#include <utility>
20
24
25#if DUNE_VERSION_GTE(DUNE_FUNCTIONS, 2, 11)
29#else
30#include <dune/typetree/childextraction.hh>
31#include <dune/typetree/treepath.hh>
32#endif
33
34
35namespace Dune::Fufem::Impl {
36
37 namespace Concept {
38
39#if DUNE_VERSION_GTE(DUNE_FUNCTIONS, 2, 11)
40
41 template<class Node>
43
44 template<class Node>
45 concept StaticDegreeInnerTreeNode = Dune::TypeTree::Concept::StaticDegreeInnerTreeNode<Node>;
46
47 template<class Node>
48 concept UniformInnerTreeNode = Dune::TypeTree::Concept::UniformInnerTreeNode<Node>;
49
50 template<class Node>
52
53 template<class Node>
55
56#else
57
58 template<class Node>
59 concept HasConstExprDegree = requires(Node node)
60 {
62 };
63
64 template<class Node>
65 concept HasPositiveDegree = ( std::remove_cvref_t<Node>::degree() > 0);
66
67
69 template<class Node>
70 concept TreeNode = requires(Node node)
71 {
73 };
74
76 template<class Node>
77 concept StaticDegreeInnerTreeNode = TreeNode<Node> && requires(Node node)
78 {
80 requires IsCompileTimeConstant<decltype(std::remove_cvref_t<Node>::degree())>::value;
81 requires HasConstExprDegree<Node> and HasPositiveDegree<Node>;
82 node.child(index_constant<0>());
84 };
85
87 template<class Node>
88 concept UniformInnerTreeNode = TreeNode<Node> && requires(Node node, std::size_t index)
89 {
90 node.child(index);
91 };
92
94 template<class Node>
95 concept InnerTreeNode = StaticDegreeInnerTreeNode<Node> || UniformInnerTreeNode<Node>;
96
98 template<class Node>
99 concept LeafTreeNode = TreeNode<Node> && not InnerTreeNode<Node>;
100
101#endif
102
103 } // namespace Concept (in Dune::Fufem::Impl::)
104
105#if DUNE_VERSION_GTE(DUNE_FUNCTIONS, 2, 11)
106
107 template<class N>
108 using Children = Dune::TypeTree::Impl::Children<N>;
109
110 template<typename... T>
112
113#else
114
115 template<typename... T>
116 using TreePath = Dune::TypeTree::HybridTreePath<T...>;
117
118 template<class N>
119 static constexpr auto childTypes()
120 {
121 if constexpr (Dune::Fufem::Impl::Concept::StaticDegreeInnerTreeNode<N>)
122 {
123 return Dune::unpackIntegerSequence([&](auto... i) {
125 }, std::make_index_sequence<N::degree()>{});
126 }
127 else
128 return Dune::MetaType<void>{};
129 }
130
132
142 template<class N>
143 using Children = typename decltype(childTypes<N>())::type;
144
145#endif
146
147} // namespace Dune::Fufem::Impl
148
149
150#endif // DUNE_FUFEM_TYPETREEFALLBACK_HH
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
std::integral_constant< std::size_t, i > index_constant
std::ptrdiff_t index() const
Dune::HybridMultiIndex< T... > TreePath
T as_const(T... args)
T forward(T... args)