Loading...
Searching...
No Matches
nodeconcepts.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
#ifndef DUNE_COMMON_TYPETREE_NODECONCEPTS_HH
#define DUNE_COMMON_TYPETREE_NODECONCEPTS_HH
#include <dune/common/typetraits.hh>
#include <dune/common/indices.hh>
#include <concepts>
#include <type_traits>
#include <utility>
namespace Dune::TypeTree::Concept {
namespace Impl {
template<class Node>
concept HasConstExprDegree = requires(Node node)
{
std::bool_constant<(std::remove_cvref_t<Node>::degree(), true)>();
};
template<class Node>
concept HasPositiveDegree = ( std::remove_cvref_t<Node>::degree() > 0);
}
template<class Node>
concept TreeNode = requires(Node node)
{
{ std::as_const(node).degree() } -> std::convertible_to<std::size_t>;
};
template<class Node>
concept StaticDegreeInnerTreeNode = TreeNode<Node> && requires(Node node)
{
std::remove_cvref_t<Node>::degree();
requires IsCompileTimeConstant<decltype(std::remove_cvref_t<Node>::degree())>::value;
requires Impl::HasConstExprDegree<Node> and Impl::HasPositiveDegree<Node>;
node.child(index_constant<0>());
node.child(index_constant<(std::remove_cvref_t<Node>::degree()-1)>());
};
template<class Node>
concept UniformInnerTreeNode = TreeNode<Node> && requires(Node node, std::size_t index)
{
node.child(index);
};
template<class Node>
concept InnerTreeNode = StaticDegreeInnerTreeNode<Node> || UniformInnerTreeNode<Node>;
template<class Node>
concept LeafTreeNode = TreeNode<Node> && not InnerTreeNode<Node>;
} // namespace Dune::TypeTree::Concept
#endif // DUNE_COMMON_TYPETREE_NODECONCEPTS_HH
typetraits.hh
Traits for type conversions and type information.
indices.hh
Dune::index_constant
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
Dune::TypeTree::Concept
Definition nodeconcepts.hh:17
Dune::IsCompileTimeConstant
Check if T is an integral constant or any type derived from std::integral_constant.
Definition typetraits.hh:411
Dune::TypeTree::Concept::TreeNode
Model of a node of a typetree.
Definition nodeconcepts.hh:34
Dune::TypeTree::Concept::StaticDegreeInnerTreeNode
Model of an inner node of a typetree with compile time known degree and child access via index_consta...
Definition nodeconcepts.hh:41
Dune::TypeTree::Concept::UniformInnerTreeNode
Model of an inner node of a typetree with uniform nodes accessible via runtime index.
Definition nodeconcepts.hh:52
Dune::TypeTree::Concept::InnerTreeNode
Model of an inner tree node of a typetree (either static degree or uniform).
Definition nodeconcepts.hh:59
Dune::TypeTree::Concept::LeafTreeNode
Model of a leaf tree node of a typetree.
Definition nodeconcepts.hh:63