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>
117 #endif // DUNE_TYPETREE_PAIRTRAVERSAL_HH