4#ifndef DUNE_TYPETREE_UTILITY_HH
5#define DUNE_TYPETREE_UTILITY_HH
40 template<
typename BaseType,
typename T>
41 T& assertGridViewType(T& t)
43 static_assert((
std::is_same<
typename BaseType::Traits::GridViewType,
44 typename T::Traits::GridViewType>::value),
45 "GridViewType must be equal in all components of composite type");
57 namespace Experimental {
67 template<
class BinaryOp,
class Arg>
68 constexpr decltype(
auto)
69 left_fold(BinaryOp&& binary_op, Arg&& arg)
95 template<
class BinaryOp,
class Init,
class Arg0,
class... Args>
96 constexpr decltype(
auto)
97 left_fold(BinaryOp&& binary_op, Init&& init, Arg0&& arg_0, Args&&... args)
110 template<
class Op,
class... Args>
111 constexpr auto applyOperator(Op&& op, Args&&... args)
114 return op(
static_cast<T
>(args)...);
117 template<
class Op,
class T, T... Args>
121 "Operator in integral expressions shall be default constructible");
122 constexpr auto result = Op{}(T{Args}...);
128 template<
class... Args>
129 constexpr auto operator()(Args&&... args)
const
132 return std::max({
static_cast<T
>(args)...});
137 static constexpr auto max = [](
const auto& a,
const auto& b)
139 return Detail::applyOperator(Detail::Max{}, a, b);
142 static constexpr auto plus = [](
const auto& a,
const auto& b)
147 static constexpr auto minus = [](
const auto& a,
const auto& b)
166 template<
typename Tree,
typename Tag = StartTag>
196 template<
typename Node>
210 template<
typename Node>
211 struct TreeInfo<Node,PowerNodeTag>
214 typedef TreeInfo<typename Node::ChildType,NodeTag<typename Node::ChildType>> ChildInfo;
229 template<
typename Node, std::
size_t k, std::
size_t n>
230 struct generic_compositenode_children_info
233 typedef generic_compositenode_children_info<Node,k+1,n> NextChild;
236 typedef typename Node::template Child<k>::Type Child;
237 typedef NodeTag<Child> ChildTag;
238 typedef TreeInfo<Child,ChildTag> ChildInfo;
241 static const std::size_t maxDepth = ChildInfo::depth > NextChild::maxDepth ? ChildInfo::depth : NextChild::maxDepth;
243 static const std::size_t nodeCount = ChildInfo::nodeCount + NextChild::nodeCount;
245 static const std::size_t leafCount = ChildInfo::leafCount + NextChild::leafCount;
250 template<
typename Node, std::
size_t n>
251 struct generic_compositenode_children_info<Node,n,n>
264 template<
typename Node>
265 struct GenericCompositeNodeInfo
268 typedef generic_compositenode_children_info<Node,0,StaticDegree<Node>::value> Children;
280 template<
typename Node>
281 struct TreeInfo<Node,CompositeNodeTag>
282 :
public GenericCompositeNodeInfo<Node>
static const result_type result
Definition accumulate_static.hh:110
auto leafCount(const Tree &tree)
The number of leaf nodes in the Tree.
Definition visitor.hh:530
auto nodeCount(const Tree &tree)
The total number of nodes in the Tree.
Definition visitor.hh:522
auto depth(const Tree &tree)
The depth of the TypeTree.
Definition visitor.hh:506
virtual void operator()()=0
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Tag designating a leaf node.
Definition nodetags.hh:16
Struct for obtaining some basic structural information about a TypeTree.
Definition utility.hh:168
static const std::size_t leafCount
The number of leaf nodes in the TypeTree.
Definition utility.hh:183
static const std::size_t depth
The depth of the TypeTree.
Definition utility.hh:177
static const std::size_t nodeCount
The total number of nodes in the TypeTree.
Definition utility.hh:180