4 #ifndef DUNE_TYPETREE_PAIRTRAVERSAL_HH
5 #define DUNE_TYPETREE_PAIRTRAVERSAL_HH
7 #include <dune/common/std/type_traits.hh>
36 template<
class T1,
class T2,
class TreePath,
class V,
37 std::enable_if_t<(std::decay_t<T1>::isLeaf or std::decay_t<T2>::isLeaf),
int> = 0>
40 visitor.leaf(tree1, tree2,
treePath);
46 template<
class T1,
class T2,
class TreePath,
class V,
47 std::enable_if_t<not(std::decay_t<T1>::isLeaf or std::decay_t<T2>::isLeaf),
int> = 0>
55 using Tree1 = std::remove_reference_t<T1>;
56 using Tree2 = std::remove_reference_t<T2>;
57 using Visitor = std::remove_reference_t<V>;
65 auto indices = Dune::range(
degree);
66 Dune::Hybrid::forEach(indices, [&](
auto i) {
68 auto&& child1 = tree1.child(i);
69 auto&& child2 = tree2.child(i);
70 using Child1 = std::decay_t<decltype(child1)>;
71 using Child2 = std::decay_t<decltype(child2)>;
73 visitor.beforeChild(tree1, child1, tree2, child2,
treePath, i);
79 static const auto visitChild = Visitor::template VisitChild<Tree1,Child1,Tree2,Child2,TreePath>::value;
80 Dune::Hybrid::ifElse(Dune::Std::bool_constant<visitChild>{}, [&] (
auto id) {
84 visitor.afterChild(tree1, child1, tree2, child2,
treePath, i);
86 visitor.post(tree1, tree2,
treePath);
106 template<
typename Tree1,
typename Tree2,
typename Visitor>
static const TreePathType::Type treePathType
Definition: traversalutilities.hh:30
void applyToTreePair(Tree1 &&tree1, Tree2 &&tree2, Visitor &&visitor)
Apply visitor to a pair of TypeTrees.
Definition: pairtraversal.hh:107
std::size_t degree(const Node &node)
Returns the degree of node as run time information.
Definition: nodeinterface.hh:71
constexpr HybridTreePath< T... > treePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:188
constexpr HybridTreePath< T... > hybridTreePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:177
constexpr HybridTreePath< T..., std::size_t > push_back(const HybridTreePath< T... > &tp, std::size_t i)
Appends a run time index to a HybridTreePath.
Definition: treepath.hh:278
HybridTreePath< Dune::index_constant< i >... > TreePath
Definition: treepath.hh:433
Definition: accumulate_static.hh:13
void applyToTreePair(T1 &&tree1, T2 &&tree2, TreePath treePath, V &&visitor)
Definition: pairtraversal.hh:38
@ dynamic
Definition: treepath.hh:30
A hybrid version of TreePath that supports both compile time and run time indices.
Definition: treepath.hh:79