Dune Core Modules (unstable)

nodeconcepts.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 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_NODECONCEPTS_HH
7#define DUNE_COMMON_TYPETREE_NODECONCEPTS_HH
8
10#include <dune/common/indices.hh>
11
12#include <concepts>
13#include <type_traits>
14#include <utility>
15
16
17namespace Dune::TypeTree::Concept {
18
19 namespace Impl {
20
21 template<class Node>
22 concept HasConstExprDegree = requires(Node node)
23 {
24 std::bool_constant<(std::remove_cvref_t<Node>::degree(), true)>();
25 };
26
27 template<class Node>
28 concept HasPositiveDegree = ( std::remove_cvref_t<Node>::degree() > 0);
29
30 }
31
33 template<class Node>
34 concept TreeNode = requires(Node node)
35 {
36 { std::as_const(node).degree() } -> std::convertible_to<std::size_t>;
37 };
38
40 template<class Node>
41 concept StaticDegreeInnerTreeNode = TreeNode<Node> && requires(Node node)
42 {
43 std::remove_cvref_t<Node>::degree();
44 requires IsCompileTimeConstant<decltype(std::remove_cvref_t<Node>::degree())>::value;
45 requires Impl::HasConstExprDegree<Node> and Impl::HasPositiveDegree<Node>;
46 node.child(index_constant<0>());
47 node.child(index_constant<(std::remove_cvref_t<Node>::degree()-1)>());
48 };
49
51 template<class Node>
52 concept UniformInnerTreeNode = TreeNode<Node> && requires(Node node, std::size_t index)
53 {
54 node.child(index);
55 };
56
58 template<class Node>
60
62 template<class Node>
64
65} // namespace Dune::TypeTree::Concept
66
67#endif // DUNE_COMMON_TYPETREE_NODECONCEPTS_HH
Model of an inner tree node of a typetree (either static degree or uniform)
Definition: nodeconcepts.hh:59
Model of a leaf tree node of a typetree.
Definition: nodeconcepts.hh:63
Model of an inner node of a typetree with compile time known degree and child access via index_consta...
Definition: nodeconcepts.hh:41
Model of a node of a typetree.
Definition: nodeconcepts.hh:34
Model of an inner node of a typetree with uniform nodes accessible via runtime index.
Definition: nodeconcepts.hh:52
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:29
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)