Commit 428e0336 authored by Simon Praetorius's avatar Simon Praetorius

Make degree an integral constant for static nodes

parent 95da207a
Pipeline #34039 passed with stage
in 2 minutes and 7 seconds
......@@ -6,6 +6,7 @@
#include <tuple>
#include <memory>
#include <type_traits>
#include <dune/typetree/nodetags.hh>
#include <dune/typetree/childextraction.hh>
......@@ -47,9 +48,9 @@ namespace Dune {
//! The number of children.
static const std::size_t CHILDREN = sizeof...(Children);
static constexpr std::size_t degree ()
static constexpr auto degree ()
{
return sizeof...(Children);
return std::integral_constant<std::size_t,sizeof...(Children)>{};
}
//! Access to the type and storage type of the i-th child.
......
......@@ -115,9 +115,9 @@ namespace Dune {
//! The number of children.
static const std::size_t CHILDREN = filter_result::size;
static constexpr std::size_t degree ()
static constexpr auto degree ()
{
return filter_result::size;
return std::integral_constant<std::size_t,filter_result::size>{};
}
//! Access to the type and storage type of the i-th child.
......
......@@ -6,6 +6,7 @@
#include <dune/typetree/nodetags.hh>
#include <cstddef>
#include <type_traits>
namespace Dune {
namespace TypeTree {
......@@ -41,9 +42,9 @@ namespace Dune {
//! The type tag that describes a LeafNode.
typedef LeafNodeTag NodeTag;
static constexpr std::size_t degree()
static constexpr auto degree()
{
return 0;
return std::integral_constant<std::size_t,0>{};
}
protected:
......
......@@ -69,15 +69,14 @@ namespace Dune {
static_assert(allowDynamicTraversal::value || allowStaticTraversal::value);
// the visitor may specify preferred dynamic traversal
using preferDynamicTraversal
= std::bool_constant<Visitor::treePathType == TreePathType::dynamic || !allowStaticTraversal::value>;
using preferDynamicTraversal = std::bool_constant<Visitor::treePathType == TreePathType::dynamic>;
// create a dynamic or static index range
auto indices = [&]{
if constexpr(preferDynamicTraversal::value && allowDynamicTraversal::value)
return Dune::range(std::size_t(tree1.degree()));
else
return std::make_index_sequence<Tree1::degree()>{};
return Dune::range(tree1.degree());
}();
if constexpr(allowDynamicTraversal::value || allowStaticTraversal::value) {
......
......@@ -63,9 +63,9 @@ namespace Dune {
//! The number of children.
static const std::size_t CHILDREN = k;
static constexpr std::size_t degree ()
static constexpr auto degree ()
{
return k;
return std::integral_constant<std::size_t,k>{};
}
//! The type tag that describes a PowerNode.
......
......@@ -116,15 +116,14 @@ namespace Dune {
static_assert(allowDynamicTraversal::value || allowStaticTraversal::value);
// the visitor may specify preferred dynamic traversal
using preferDynamicTraversal
= std::bool_constant<Visitor::treePathType == TreePathType::dynamic || !allowStaticTraversal::value>;
using preferDynamicTraversal = std::bool_constant<Visitor::treePathType == TreePathType::dynamic>;
// create a dynamic or static index range
auto indices = [&]{
if constexpr(preferDynamicTraversal::value && allowDynamicTraversal::value)
return Dune::range(std::size_t(tree.degree()));
else
return std::make_index_sequence<Tree::degree()>{};
return Dune::range(tree.degree());
}();
if constexpr(allowDynamicTraversal::value || allowStaticTraversal::value) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment