4 #ifndef DUNE_TYPETREE_APPLYTOCHILDRENTREEPAIR_HH
5 #define DUNE_TYPETREE_APPLYTOCHILDRENTREEPAIR_HH
7 #include <dune/common/typetraits.hh>
13 #if HAVE_RVALUE_REFERENCES
25 #ifndef DOXYGEN // these are all internals and not public API. Only access is using applyToTree().
28 template<TreePathType::Type tpType,
typename tag1 = StartTag,
typename tag2 = StartTag,
bool doApply = true>
29 struct ApplyToTreePair;
36 template<std::
size_t inverse_k, std::
size_t count>
37 struct apply_to_children_pair_fully_static
40 #if HAVE_RVALUE_REFERENCES
42 template<
typename N1,
typename N2,
typename V,
typename TreePath>
43 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
45 typedef typename remove_reference<N1>::type::template Child<count-inverse_k>
::Type C1;
46 typedef typename remove_reference<N2>::type::template Child<count-inverse_k>
::Type C2;
47 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
48 const bool visit = std::remove_reference<V>::type
49 ::template VisitChild<typename remove_reference<N1>::type,
51 typename remove_reference<N2>::type,
54 v.beforeChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
55 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
56 tp,integral_constant<std::size_t,count-inverse_k>());
60 visit>::apply(n1.template child<count-inverse_k>(),
61 n2.template child<count-inverse_k>(),
64 v.afterChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
65 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
66 tp,integral_constant<std::size_t,count-inverse_k>());
67 v.in(std::forward<N1>(n1),std::forward<N2>(n2),tp);
68 apply_to_children_pair_fully_static<inverse_k-1,count>::apply(std::forward<N1>(n1),
76 template<
typename N1,
typename N2,
typename V,
typename TreePath>
77 static void apply(N1& n1, N2& n2, V& v, TreePath tp)
79 typedef typename N1::template Child<count-inverse_k>
::Type C1;
80 typedef typename N2::template Child<count-inverse_k>
::Type C2;
81 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
83 v.beforeChild(n1,n1.template child<count-inverse_k>(),
84 n2,n2.template child<count-inverse_k>(),
86 integral_constant<std::size_t,count-inverse_k>());
90 visit>::apply(n1.template child<count-inverse_k>(),
91 n2.template child<count-inverse_k>(),
94 v.afterChild(n1,n1.template child<count-inverse_k>(),
95 n2,n2.template child<count-inverse_k>(),
97 integral_constant<std::size_t,count-inverse_k>());
99 apply_to_children_pair_fully_static<inverse_k-1,count>::apply(n1,n2,v,tp);
102 template<
typename N1,
typename N2,
typename V,
typename TreePath>
103 static void apply(
const N1& n1,
const N2& n2, V& v, TreePath tp)
105 typedef typename N1::template Child<count-inverse_k>
::Type C1;
106 typedef typename N2::template Child<count-inverse_k>
::Type C2;
107 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
108 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
109 v.beforeChild(n1,n1.template child<count-inverse_k>(),
110 n2,n2.template child<count-inverse_k>(),
112 integral_constant<std::size_t,count-inverse_k>());
114 typename C1::NodeTag,
115 typename C2::NodeTag,
116 visit>::apply(n1.template child<count-inverse_k>(),
117 n2.template child<count-inverse_k>(),
120 v.afterChild(n1,n1.template child<count-inverse_k>(),
121 n2,n2.template child<count-inverse_k>(),
123 integral_constant<std::size_t,count-inverse_k>());
125 apply_to_children_pair_fully_static<inverse_k-1,count>::apply(n1,n2,v,tp);
128 template<
typename N1,
typename N2,
typename V,
typename TreePath>
129 static void apply(N1& n1, N2& n2,
const V& v, TreePath tp)
131 typedef typename N1::template Child<count-inverse_k>
::Type C1;
132 typedef typename N2::template Child<count-inverse_k>
::Type C2;
133 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
134 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
135 v.beforeChild(n1,n1.template child<count-inverse_k>(),
136 n2,n2.template child<count-inverse_k>(),
138 integral_constant<std::size_t,count-inverse_k>());
140 typename C1::NodeTag,
141 typename C2::NodeTag,
142 visit>::apply(n1.template child<count-inverse_k>(),
143 n2.template child<count-inverse_k>(),
146 v.afterChild(n1,n1.template child<count-inverse_k>(),
147 n2,n2.template child<count-inverse_k>(),
149 integral_constant<std::size_t,count-inverse_k>());
151 apply_to_children_pair_fully_static<inverse_k-1,count>::apply(n1,n2,v,tp);
154 template<
typename N1,
typename N2,
typename V,
typename TreePath>
155 static void apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp)
157 typedef typename N1::template Child<count-inverse_k>
::Type C1;
158 typedef typename N2::template Child<count-inverse_k>
::Type C2;
159 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
160 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
161 v.beforeChild(n1,n1.template child<count-inverse_k>(),
162 n2,n2.template child<count-inverse_k>(),
164 integral_constant<std::size_t,count-inverse_k>());
166 typename C1::NodeTag,
167 typename C2::NodeTag,
168 visit>::apply(n1.template child<count-inverse_k>(),
169 n2.template child<count-inverse_k>(),
172 v.afterChild(n1,n1.template child<count-inverse_k>(),
173 n2,n2.template child<count-inverse_k>(),
175 integral_constant<std::size_t,count-inverse_k>());
177 apply_to_children_pair_fully_static<inverse_k-1,count>::apply(n1,n2,v,tp);
180 #endif // HAVE_RVALUE_REFERENCES
186 template<std::
size_t count>
187 struct apply_to_children_pair_fully_static<1,count>
190 #if HAVE_RVALUE_REFERENCES
192 template<
typename N1,
typename N2,
typename V,
typename TreePath>
193 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
195 typedef typename remove_reference<N1>::type::template Child<count-1>
::Type C1;
196 typedef typename remove_reference<N2>::type::template Child<count-1>
::Type C2;
197 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
198 const bool visit = std::remove_reference<V>::type
199 ::template VisitChild<typename remove_reference<N1>::type,
201 typename remove_reference<N2>::type,
204 v.beforeChild(std::forward<N1>(n1),n1.template child<count-1>(),
205 std::forward<N2>(n2),n2.template child<count-1>(),
206 tp,integral_constant<std::size_t,count-1>());
208 typename C1::NodeTag,
209 typename C2::NodeTag,
210 visit>::apply(n1.template child<count-1>(),
211 n2.template child<count-1>(),
214 v.afterChild(std::forward<N1>(n1),n1.template child<count-1>(),
215 std::forward<N2>(n2),n2.template child<count-1>(),
216 tp,integral_constant<std::size_t,count-1>());
221 template<
typename N1,
typename N2,
typename V,
typename TreePath>
222 static void apply(N1& n1, N2& n2, V& v, TreePath tp)
224 typedef typename N1::template Child<count-1>
::Type C1;
225 typedef typename N2::template Child<count-1>
::Type C2;
226 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
227 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
228 v.beforeChild(n1,n1.template child<count-1>(),
229 n2,n2.template child<count-1>(),
231 integral_constant<std::size_t,count-1>());
233 typename C1::NodeTag,
234 typename C2::NodeTag,
235 visit>::apply(n1.template child<count-1>(),
236 n2.template child<count-1>(),
239 v.afterChild(n1,n1.template child<count-1>(),
240 n2,n2.template child<count-1>(),
242 integral_constant<std::size_t,count-1>());
245 template<
typename N1,
typename N2,
typename V,
typename TreePath>
246 static void apply(
const N1& n1,
const N2& n2, V& v, TreePath tp)
248 typedef typename N1::template Child<count-1>
::Type C1;
249 typedef typename N2::template Child<count-1>
::Type C2;
250 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
251 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
252 v.beforeChild(n1,n1.template child<count-1>(),
253 n2,n2.template child<count-1>(),
255 integral_constant<std::size_t,count-1>());
257 typename C1::NodeTag,
258 typename C2::NodeTag,
259 visit>::apply(n1.template child<count-1>(),
260 n2.template child<count-1>(),
263 v.afterChild(n1,n1.template child<count-1>(),
264 n2,n2.template child<count-1>(),
266 integral_constant<std::size_t,count-1>());
269 template<
typename N1,
typename N2,
typename V,
typename TreePath>
270 static void apply(N1& n1, N2& n2,
const V& v, TreePath tp)
272 typedef typename N1::template Child<count-1>
::Type C1;
273 typedef typename N2::template Child<count-1>
::Type C2;
274 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
275 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
276 v.beforeChild(n1,n1.template child<count-1>(),
277 n2,n2.template child<count-1>(),
279 integral_constant<std::size_t,count-1>());
281 typename C1::NodeTag,
282 typename C2::NodeTag,
283 visit>::apply(n1.template child<count-1>(),
284 n2.template child<count-1>(),
287 v.afterChild(n1,n1.template child<count-1>(),
288 n2,n2.template child<count-1>(),
290 integral_constant<std::size_t,count-1>());
293 template<
typename N1,
typename N2,
typename V,
typename TreePath>
294 static void apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp)
296 typedef typename N1::template Child<count-1>
::Type C1;
297 typedef typename N2::template Child<count-1>
::Type C2;
298 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
299 const bool visit = V::template VisitChild<N1,C1,N2,C2,ChildTreePath>::value;
300 v.beforeChild(n1,n1.template child<count-1>(),
301 n2,n2.template child<count-1>(),
303 integral_constant<std::size_t,count-1>());
305 typename C1::NodeTag,
306 typename C2::NodeTag,
307 visit>::apply(n1.template child<count-1>(),
308 n2.template child<count-1>(),
311 v.afterChild(n1,n1.template child<count-1>(),
312 n2,n2.template child<count-1>(),
314 integral_constant<std::size_t,count-1>());
317 #endif // HAVE_RVALUE_REFERENCES
323 struct apply_to_children_pair_fully_static<0,0>
326 #if HAVE_RVALUE_REFERENCES
328 template<
typename N1,
typename N2,
typename V,
typename TreePath>
329 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp) {}
333 template<
typename N1,
typename N2,
typename V,
typename TreePath>
334 static void apply(N1& n1, N2& n2, V& v, TreePath tp) {}
336 template<
typename N1,
typename N2,
typename V,
typename TreePath>
337 static void apply(
const N1& n1,
const N2& n2, V& v, TreePath tp) {}
339 template<
typename N1,
typename N2,
typename V,
typename TreePath>
340 static void apply(N1& n1, N2& n2,
const V& v, TreePath tp) {}
342 template<
typename N1,
typename N2,
typename V,
typename TreePath>
343 static void apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp) {}
345 #endif // HAVE_RVALUE_REFERENCES
354 template<std::
size_t inverse_k, std::
size_t count>
355 struct apply_to_children_pair_dynamic
358 #if HAVE_RVALUE_REFERENCES
360 template<
typename N1,
typename N2,
typename V,
typename TreePath>
361 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
363 typedef typename remove_reference<N1>::type::template Child<count-inverse_k>
::Type C1;
364 typedef typename remove_reference<N2>::type::template Child<count-inverse_k>
::Type C2;
365 const bool visit = std::remove_reference<V>::type
366 ::template VisitChild<typename remove_reference<N1>::type,
368 typename remove_reference<N2>::type,
371 v.beforeChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
372 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
373 tp.view(),count-inverse_k);
374 tp.push_back(count-inverse_k);
376 typename C1::NodeTag,
377 typename C2::NodeTag,
378 visit>::apply(n1.template child<count-inverse_k>(),
379 n2.template child<count-inverse_k>(),
383 v.afterChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
384 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
385 tp.view(),count-inverse_k);
386 v.in(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
387 apply_to_children_pair_dynamic<inverse_k-1,count>::apply(std::forward<N1>(n1),
388 std::forward<N2>(n2),
395 template<
typename N1,
typename N2,
typename V,
typename TreePath>
396 static void apply(N1& n1, N2& n2, V& v, TreePath tp)
398 typedef typename N1::template Child<count-inverse_k>
::Type C1;
399 typedef typename N2::template Child<count-inverse_k>
::Type C2;
401 v.beforeChild(n1,n1.template child<count-inverse_k>(),
402 n2,n2.template child<count-inverse_k>(),
403 tp.view(),count-inverse_k);
404 tp.push_back(count-inverse_k);
406 typename C1::NodeTag,
407 typename C2::NodeTag,
408 visit>::apply(n1.template child<count-inverse_k>(),
409 n2.template child<count-inverse_k>(),
413 v.afterChild(n1,n1.template child<count-inverse_k>(),
414 n2,n2.template child<count-inverse_k>(),
415 tp.view(),count-inverse_k);
416 v.in(n1,n2,tp.view());
417 apply_to_children_pair_dynamic<inverse_k-1,count>::apply(n1,n2,v,tp);
420 template<
typename N1,
typename N2,
typename V,
typename TreePath>
421 static void apply(
const N1& n1,
const N2& n2, V& v, TreePath tp) {
422 typedef typename N1::template Child<count-inverse_k>
::Type C1;
423 typedef typename N2::template Child<count-inverse_k>
::Type C2;
424 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
425 v.beforeChild(n1,n1.template child<count-inverse_k>(),
426 n2,n2.template child<count-inverse_k>(),
427 tp.view(),count-inverse_k);
428 tp.push_back(count-inverse_k);
430 typename C1::NodeTag,
431 typename C2::NodeTag,
432 visit>::apply(n1.template child<count-inverse_k>(),
433 n2.template child<count-inverse_k>(),
437 v.afterChild(n1,n1.template child<count-inverse_k>(),
438 n2,n2.template child<count-inverse_k>(),
439 tp.view(),count-inverse_k);
440 v.in(n1,n2,tp.view());
441 apply_to_children_pair_dynamic<inverse_k-1,count>::apply(n1,n2,v,tp);
444 template<
typename N1,
typename N2,
typename V,
typename TreePath>
445 static void apply(N1& n1, N2& n2,
const V& v, TreePath tp)
447 typedef typename N1::template Child<count-inverse_k>
::Type C1;
448 typedef typename N2::template Child<count-inverse_k>
::Type C2;
449 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
450 v.beforeChild(n1,n1.template child<count-inverse_k>(),
451 n2,n2.template child<count-inverse_k>(),
452 tp.view(),count-inverse_k);
453 tp.push_back(count-inverse_k);
455 typename C1::NodeTag,
456 typename C2::NodeTag,
457 visit>::apply(n1.template child<count-inverse_k>(),
458 n2.template child<count-inverse_k>(),
462 v.afterChild(n1,n1.template child<count-inverse_k>(),
463 n2,n2.template child<count-inverse_k>(),
464 tp.view(),count-inverse_k);
465 v.in(n1,n2,tp.view());
466 apply_to_children_pair_dynamic<inverse_k-1,count>::apply(n1,n2,v,tp);
469 template<
typename N1,
typename N2,
typename V,
typename TreePath>
470 static void apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp)
472 typedef typename N1::template Child<count-inverse_k>
::Type C1;
473 typedef typename N2::template Child<count-inverse_k>
::Type C2;
474 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
475 v.beforeChild(n1,n1.template child<count-inverse_k>(),
476 n2,n2.template child<count-inverse_k>(),
477 tp.view(),count-inverse_k);
478 tp.push_back(count-inverse_k);
480 typename C1::NodeTag,
481 typename C2::NodeTag,
482 visit>::apply(n1.template child<count-inverse_k>(),
483 n2.template child<count-inverse_k>(),
487 v.afterChild(n1,n1.template child<count-inverse_k>(),
488 n2,n2.template child<count-inverse_k>(),
489 tp.view(),count-inverse_k);
490 v.in(n1,n2,tp.view());
491 apply_to_children_pair_dynamic<inverse_k-1,count>::apply(n1,n2,v,tp);
494 #endif // HAVE_RVALUE_REFERENCES
500 template<std::
size_t count>
501 struct apply_to_children_pair_dynamic<1,count>
504 #if HAVE_RVALUE_REFERENCES
506 template<
typename N1,
typename N2,
typename V,
typename TreePath>
507 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
509 typedef typename remove_reference<N1>::type::template Child<count-1>
::Type C1;
510 typedef typename remove_reference<N2>::type::template Child<count-1>
::Type C2;
511 const bool visit = std::remove_reference<V>::type
512 ::template VisitChild<typename remove_reference<N1>::type,
514 typename remove_reference<N2>::type,
517 v.beforeChild(std::forward<N1>(n1),n1.template child<count-1>(),
518 std::forward<N2>(n2),n2.template child<count-1>(),
520 tp.push_back(count-1);
522 typename C1::NodeTag,
523 typename C2::NodeTag,
524 visit>::apply(n1.template child<count-1>(),
525 n2.template child<count-1>(),
529 v.afterChild(std::forward<N1>(n1),n1.template child<count-1>(),
530 std::forward<N2>(n2),n2.template child<count-1>(),
536 template<
typename N1,
typename N2,
typename V,
typename TreePath>
537 static void apply(N1& n1, N2& n2, V& v, TreePath tp)
539 typedef typename N1::template Child<count-1>
::Type C1;
540 typedef typename N2::template Child<count-1>
::Type C2;
541 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
542 v.beforeChild(n1,n1.template child<count-1>(),
543 n2,n2.template child<count-1>(),
545 tp.push_back(count-1);
547 typename C1::NodeTag,
548 typename C2::NodeTag,
549 visit>::apply(n1.template child<count-1>(),
550 n2.template child<count-1>(),
554 v.afterChild(n1,n1.template child<count-1>(),
555 n2,n2.template child<count-1>(),
559 template<
typename N1,
typename N2,
typename V,
typename TreePath>
560 static void apply(
const N1& n1,
const N2& n2, V& v, TreePath tp)
562 typedef typename N1::template Child<count-1>
::Type C1;
563 typedef typename N2::template Child<count-1>
::Type C2;
564 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
565 v.beforeChild(n1,n1.template child<count-1>(),
566 n2,n2.template child<count-1>(),
568 tp.push_back(count-1);
570 typename C1::NodeTag,
571 typename C2::NodeTag,
572 visit>::apply(n1.template child<count-1>(),
573 n2.template child<count-1>(),
577 v.afterChild(n1,n1.template child<count-1>(),
578 n2,n2.template child<count-1>(),
582 template<
typename N1,
typename N2,
typename V,
typename TreePath>
583 static void apply(N1& n1, N2& n2,
const V& v, TreePath tp)
585 typedef typename N1::template Child<count-1>
::Type C1;
586 typedef typename N2::template Child<count-1>
::Type C2;
587 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
588 v.beforeChild(n1,n1.template child<count-1>(),
589 n2,n2.template child<count-1>(),
591 tp.push_back(count-1);
593 typename C1::NodeTag,
594 typename C2::NodeTag,
595 visit>::apply(n1.template child<count-1>(),
596 n2.template child<count-1>(),
600 v.afterChild(n1,n1.template child<count-1>(),
601 n2,n2.template child<count-1>(),
605 template<
typename N1,
typename N2,
typename V,
typename TreePath>
606 static void apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp)
608 typedef typename N1::template Child<count-1>
::Type C1;
609 typedef typename N2::template Child<count-1>
::Type C2;
610 const bool visit = V::template VisitChild<N1,C1,N2,C2,typename TreePath::ViewType>::value;
611 v.beforeChild(n1,n1.template child<count-1>(),
612 n2,n2.template child<count-1>(),
614 tp.push_back(count-1);
616 typename C1::NodeTag,
617 typename C2::NodeTag,
618 visit>::apply(n1.template child<count-1>(),
619 n2.template child<count-1>(),
623 v.afterChild(n1,n1.template child<count-1>(),
624 n2,n2.template child<count-1>(),
628 #endif // HAVE_RVALUE_REFERENCES
634 struct apply_to_children_pair_dynamic<0,0>
637 #if HAVE_RVALUE_REFERENCES
639 template<
typename N1,
typename N2,
typename V,
typename TreePath>
640 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp) {}
644 template<
typename N1,
typename N2,
typename V,
typename TreePath>
645 static void apply(N1& n1, N2& n2, V& v, TreePath tp) {}
647 template<
typename N1,
typename N2,
typename V,
typename TreePath>
648 static void apply(
const N1& n1,
const N2& n2, V& v, TreePath tp) {}
650 template<
typename N1,
typename N2,
typename V,
typename TreePath>
651 static void apply(N1& n1, N2& n2,
const V& v, TreePath tp) {}
653 template<
typename N1,
typename N2,
typename V,
typename TreePath>
654 static void apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp) {}
656 #endif // HAVE_RVALUE_REFERENCES
662 template<TreePathType::Type treePathType, std::
size_t CHILDREN>
663 struct apply_to_children_pair;
665 template<std::
size_t CHILDREN>
666 struct apply_to_children_pair<TreePathType::
fullyStatic,CHILDREN>
667 :
public apply_to_children_pair_fully_static<CHILDREN,CHILDREN>
670 template<std::
size_t CHILDREN>
671 struct apply_to_children_pair<TreePathType::
dynamic,CHILDREN>
672 :
public apply_to_children_pair_dynamic<CHILDREN,CHILDREN>
680 template<TreePathType::Type treePathType>
681 struct ApplyToGenericCompositeNodePair
684 #if HAVE_RVALUE_REFERENCES
687 template<
typename N1,
typename N2,
typename V,
typename TreePath>
688 static typename enable_if<(remove_reference<N1>::type::isLeaf || remove_reference<N2>::type::isLeaf)>::type
689 apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
691 v.leaf(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
695 template<
typename N1,
typename N2,
typename V,
typename TreePath>
696 static typename enable_if<!(remove_reference<N1>::type::isLeaf || remove_reference<N2>::type::isLeaf)>::type
697 apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
699 v.pre(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
700 typedef typename remove_reference<N1>::type Node1;
701 typedef typename remove_reference<N2>::type Node2;
704 dune_static_assert(Node1::CHILDREN == Node2::CHILDREN,
705 "non-leaf nodes with different numbers of children " \
706 "are not allowed during simultaneous grid traversal");
707 apply_to_children_pair<treePathType,Node1::CHILDREN>::apply(std::forward<N1>(n1),
708 std::forward<N2>(n2),
711 v.post(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
716 template<
typename N1,
typename N2,
typename V,
typename TreePath>
717 static typename enable_if<N1::isLeaf || N2::isLeaf>::type
718 apply(N1& n1, N2& n2, V& v, TreePath tp)
720 v.leaf(n1,n2,tp.view());
723 template<
typename N1,
typename N2,
typename V,
typename TreePath>
724 static typename enable_if<N1::isLeaf || N2::isLeaf>::type
725 apply(
const N1& n1,
const N2& n2, V& v, TreePath tp)
727 v.leaf(n1,n2,tp.view());
730 template<
typename N1,
typename N2,
typename V,
typename TreePath>
731 static typename enable_if<N1::isLeaf || N2::isLeaf>::type
732 apply(N1& n1, N2& n2,
const V& v, TreePath tp)
734 v.leaf(n1,n2,tp.view());
737 template<
typename N1,
typename N2,
typename V,
typename TreePath>
738 static typename enable_if<N1::isLeaf || N2::isLeaf>::type
739 apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp)
741 v.leaf(n1,n2,tp.view());
745 template<
typename N1,
typename N2,
typename V,
typename TreePath>
746 static typename enable_if<!(N1::isLeaf || N2::isLeaf)>::type
747 apply(N1& n1, N2& n2, V& v, TreePath tp)
749 v.pre(n1,n2,tp.view());
750 dune_static_assert(N1::CHILDREN == N2::CHILDREN,
751 "non-leaf nodes with different numbers of children " \
752 "are not allowed during simultaneous grid traversal");
753 apply_to_children_pair<treePathType,N1::CHILDREN>::apply(n1,n2,v,tp);
754 v.post(n1,n2,tp.view());
757 template<
typename N1,
typename N2,
typename V,
typename TreePath>
758 static typename enable_if<!(N1::isLeaf || N2::isLeaf)>::type
759 apply(
const N1& n1,
const N2& n2, V& v, TreePath tp)
761 v.pre(n1,n2,tp.view());
762 dune_static_assert(N1::CHILDREN == N2::CHILDREN,
763 "non-leaf nodes with different numbers of children " \
764 "are not allowed during simultaneous grid traversal");
765 apply_to_children_pair<treePathType,N1::CHILDREN>::apply(n1,n2,v,tp);
766 v.post(n1,n2,tp.view());
769 template<
typename N1,
typename N2,
typename V,
typename TreePath>
770 static typename enable_if<!(N1::isLeaf || N2::isLeaf)>::type
771 apply(N1& n1, N2& n2,
const V& v, TreePath tp)
773 v.pre(n1,n2,tp.view());
774 dune_static_assert(N1::CHILDREN == N2::CHILDREN,
775 "non-leaf nodes with different numbers of children " \
776 "are not allowed during simultaneous grid traversal");
777 apply_to_children_pair<treePathType,N1::CHILDREN>::apply(n1,n2,v,tp);
778 v.post(n1,n2,tp.view());
781 template<
typename N1,
typename N2,
typename V,
typename TreePath>
782 static typename enable_if<!(N1::isLeaf || N2::isLeaf)>::type
783 apply(
const N1& n1,
const N2& n2,
const V& v, TreePath tp)
785 v.pre(n1,n2,tp.view());
786 dune_static_assert(N1::CHILDREN == N2::CHILDREN,
787 "non-leaf nodes with different numbers of children " \
788 "are not allowed during simultaneous grid traversal");
789 apply_to_children_pair<treePathType,N1::CHILDREN>::apply(n1,n2,v,tp);
790 v.post(n1,n2,tp.view());
793 #endif // HAVE_RVALUE_REFERENCES
805 #endif // DUNE_TYPETREE_APPLYTOCHILDRENTREEPAIR_HH
Definition: treepath.hh:26
Definition: treepath.hh:26
static const TreePathType::Type treePathType
Definition: traversalutilities.hh:30
static const std::size_t value
Definition: compositenode.hh:38
Type
Definition: treepath.hh:26
TreePath ViewType
Definition: treepath.hh:33