4#ifndef DUNE_TUPLE_UTILITY_HH
5#define DUNE_TUPLE_UTILITY_HH
10#include <dune/common/std/type_traits.hh>
33 template <
class Tuple>
36 "unspecialized version of NullPointerInitialiser. "
37 "NullPointerInitialiser needs to be specialized for "
38 "each possible tuple size. Naturally the number of "
39 "pre-defined specializations is limited arbitrarily. "
40 "Maybe you need to raise this limit by defining some "
41 "more specializations? Also check that the tuple this "
42 "is applied to really is a tuple of pointers only.");
59 struct NullPointerInitialiser<tuple<> > {
67 struct NullPointerInitialiser<tuple<T0*> > {
68 typedef tuple<T0*> ResultType;
69 static ResultType apply() {
70 return ResultType(
static_cast<T0*
>(0));
74 template<
class T0,
class T1>
75 struct NullPointerInitialiser<tuple<T0*, T1*> > {
76 typedef tuple<T0*, T1*> ResultType;
77 static ResultType apply() {
78 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0));
82 template<
class T0,
class T1,
class T2>
83 struct NullPointerInitialiser<tuple<T0*, T1*, T2*> > {
84 typedef tuple<T0*, T1*, T2*> ResultType;
85 static ResultType apply() {
86 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
91 template<
class T0,
class T1,
class T2,
class T3>
92 struct NullPointerInitialiser<tuple<T0*, T1*, T2*, T3*> > {
93 typedef tuple<T0*, T1*, T2*, T3*> ResultType;
94 static ResultType apply() {
95 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
96 static_cast<T2*
>(0),
static_cast<T3*
>(0));
100 template<
class T0,
class T1,
class T2,
class T3,
class T4>
101 struct NullPointerInitialiser<tuple<T0*, T1*, T2*, T3*, T4*> > {
102 typedef tuple<T0*, T1*, T2*, T3*, T4*> ResultType;
103 static ResultType apply() {
104 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
105 static_cast<T2*
>(0),
static_cast<T3*
>(0),
106 static_cast<T4*
>(0));
110 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5>
111 struct NullPointerInitialiser<tuple<T0*, T1*, T2*, T3*, T4*, T5*> > {
112 typedef tuple<T0*, T1*, T2*, T3*, T4*, T5*> ResultType;
113 static ResultType apply() {
114 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
115 static_cast<T2*
>(0),
static_cast<T3*
>(0),
116 static_cast<T4*
>(0),
static_cast<T5*
>(0));
120 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
122 struct NullPointerInitialiser<tuple<T0*, T1*, T2*, T3*, T4*, T5*, T6*> > {
123 typedef tuple<T0*, T1*, T2*, T3*, T4*, T5*, T6*> ResultType;
124 static ResultType apply() {
125 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
126 static_cast<T2*
>(0),
static_cast<T3*
>(0),
127 static_cast<T4*
>(0),
static_cast<T5*
>(0),
128 static_cast<T6*
>(0));
132 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
134 struct NullPointerInitialiser<tuple<T0*, T1*, T2*, T3*, T4*, T5*, T6*,
136 typedef tuple<T0*, T1*, T2*, T3*, T4*, T5*, T6*, T7*> ResultType;
137 static ResultType apply() {
138 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
139 static_cast<T2*
>(0),
static_cast<T3*
>(0),
140 static_cast<T4*
>(0),
static_cast<T5*
>(0),
141 static_cast<T6*
>(0),
static_cast<T7*
>(0));
145 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
146 class T6,
class T7,
class T8>
147 struct NullPointerInitialiser<tuple<T0*, T1*, T2*, T3*, T4*, T5*, T6*,
149 typedef tuple<T0*, T1*, T2*, T3*, T4*, T5*, T6*, T7*, T8*> ResultType;
150 static ResultType apply() {
151 return ResultType(
static_cast<T0*
>(0),
static_cast<T1*
>(0),
152 static_cast<T2*
>(0),
static_cast<T3*
>(0),
153 static_cast<T4*
>(0),
static_cast<T5*
>(0),
154 static_cast<T6*
>(0),
static_cast<T7*
>(0),
155 static_cast<T8*
>(0));
195 template <
template <
class>
class TypeEvaluator,
class TupleType>
198 "unspecialized version of ForEachType. ForEachType "
199 "needs to be specialized for each possible tuple "
200 "size. Naturally the number of pre-defined "
201 "specializations is limited arbitrarily. Maybe you "
202 "need to raise this limit by defining some more "
204 struct ImplementationDefined {};
207 typedef ImplementationDefined
Type;
211 template <
template <
class>
class TE,
class Tuple>
216 template <
template <
class>
class TE>
217 struct ForEachType<TE, tuple<> > {
218 typedef tuple<>
Type;
221 template <
template <
class>
class TE,
class T0>
222 struct ForEachType<TE, tuple<T0> > {
223 typedef tuple<typename TE<T0>::Type>
Type;
226 template <
template <
class>
class TE,
class T0,
class T1>
227 struct ForEachType<TE, tuple<T0, T1> > {
228 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type>
Type;
231 template <
template <
class>
class TE,
class T0,
class T1,
class T2>
232 struct ForEachType<TE, tuple<T0, T1, T2> > {
233 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
234 typename TE<T2>::Type>
Type;
237 template <
template <
class>
class TE,
class T0,
class T1,
class T2,
class T3>
238 struct ForEachType<TE, tuple<T0, T1, T2, T3> > {
239 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
240 typename TE<T2>::Type,
typename TE<T3>::Type>
Type;
243 template <
template <
class>
class TE,
class T0,
class T1,
class T2,
class T3,
245 struct ForEachType<TE, tuple<T0, T1, T2, T3, T4> > {
246 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
247 typename TE<T2>::Type,
typename TE<T3>::Type,
248 typename TE<T4>::Type>
Type;
251 template <
template <
class>
class TE,
class T0,
class T1,
class T2,
class T3,
253 struct ForEachType<TE, tuple<T0, T1, T2, T3, T4, T5> > {
254 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
255 typename TE<T2>::Type,
typename TE<T3>::Type,
256 typename TE<T4>::Type,
typename TE<T5>::Type>
Type;
259 template <
template <
class>
class TE,
class T0,
class T1,
class T2,
class T3,
260 class T4,
class T5,
class T6>
261 struct ForEachType<TE, tuple<T0, T1, T2, T3, T4, T5, T6> > {
262 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
263 typename TE<T2>::Type,
typename TE<T3>::Type,
264 typename TE<T4>::Type,
typename TE<T5>::Type,
265 typename TE<T6>::Type>
Type;
268 template <
template <
class>
class TE,
class T0,
class T1,
class T2,
class T3,
269 class T4,
class T5,
class T6,
class T7>
270 struct ForEachType<TE, tuple<T0, T1, T2, T3, T4, T5, T6, T7> > {
271 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
272 typename TE<T2>::Type,
typename TE<T3>::Type,
273 typename TE<T4>::Type,
typename TE<T5>::Type,
274 typename TE<T6>::Type,
typename TE<T7>::Type>
Type;
277 template <
template <
class>
class TE,
class T0,
class T1,
class T2,
class T3,
278 class T4,
class T5,
class T6,
class T7,
class T8>
279 struct ForEachType<TE, tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> > {
280 typedef tuple<typename TE<T0>::Type,
typename TE<T1>::Type,
281 typename TE<T2>::Type,
typename TE<T3>::Type,
282 typename TE<T4>::Type,
typename TE<T5>::Type,
283 typename TE<T6>::Type,
typename TE<T7>::Type,
284 typename TE<T8>::Type>
Type;
336 template<
class Functor>
337 typename ForEachType<Functor::template TypeEvaluator,
339 genericTransformTupleBackend
340 (
const tuple<>& t,
const Functor& f)
342 return typename ForEachType<Functor::template TypeEvaluator,
348 template<
class T0,
class Functor>
349 typename ForEachType<Functor::template TypeEvaluator,
351 genericTransformTupleBackend
352 (tuple<T0>& t, Functor& f)
354 return typename ForEachType<Functor::template TypeEvaluator,
358 template<
class T0,
class Functor>
359 typename ForEachType<Functor::template TypeEvaluator,
361 genericTransformTupleBackend
362 (
const tuple<T0>& t, Functor& f)
364 return typename ForEachType<Functor::template TypeEvaluator,
370 template<
class T0,
class T1,
class Functor>
371 typename ForEachType<Functor::template TypeEvaluator,
372 tuple<T0, T1> >::Type
373 genericTransformTupleBackend
374 (tuple<T0, T1>& t, Functor& f)
376 return typename ForEachType<Functor::template TypeEvaluator,
377 tuple<T0, T1> >::Type
378 (f(get<0>(t)), f(get<1>(t)));
380 template<
class T0,
class T1,
class Functor>
381 typename ForEachType<Functor::template TypeEvaluator,
382 tuple<T0, T1> >::Type
383 genericTransformTupleBackend
384 (
const tuple<T0, T1>& t, Functor& f)
386 return typename ForEachType<Functor::template TypeEvaluator,
387 tuple<T0, T1> >::Type
388 (f(get<0>(t)), f(get<1>(t)));
392 template<
class T0,
class T1,
class T2,
class Functor>
393 typename ForEachType<Functor::template TypeEvaluator,
394 tuple<T0, T1, T2> >::Type
395 genericTransformTupleBackend
396 (tuple<T0, T1, T2>& t, Functor& f)
398 return typename ForEachType<Functor::template TypeEvaluator,
399 tuple<T0, T1, T2> >::Type
400 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)));
402 template<
class T0,
class T1,
class T2,
class Functor>
403 typename ForEachType<Functor::template TypeEvaluator,
404 tuple<T0, T1, T2> >::Type
405 genericTransformTupleBackend
406 (
const tuple<T0, T1, T2>& t, Functor& f)
408 return typename ForEachType<Functor::template TypeEvaluator,
409 tuple<T0, T1, T2> >::Type
410 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)));
414 template<
class T0,
class T1,
class T2,
class T3,
class Functor>
415 typename ForEachType<Functor::template TypeEvaluator,
416 tuple<T0, T1, T2, T3> >::Type
417 genericTransformTupleBackend
418 (tuple<T0, T1, T2, T3>& t, Functor& f)
420 return typename ForEachType<Functor::template TypeEvaluator,
421 tuple<T0, T1, T2, T3> >::Type
422 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)));
424 template<
class T0,
class T1,
class T2,
class T3,
class Functor>
425 typename ForEachType<Functor::template TypeEvaluator,
426 tuple<T0, T1, T2, T3> >::Type
427 genericTransformTupleBackend
428 (
const tuple<T0, T1, T2, T3>& t, Functor& f)
430 return typename ForEachType<Functor::template TypeEvaluator,
431 tuple<T0, T1, T2, T3> >::Type
432 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)));
436 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class Functor>
437 typename ForEachType<Functor::template TypeEvaluator,
438 tuple<T0, T1, T2, T3, T4> >::Type
439 genericTransformTupleBackend
440 (tuple<T0, T1, T2, T3, T4>& t, Functor& f)
442 return typename ForEachType<Functor::template TypeEvaluator,
443 tuple<T0, T1, T2, T3, T4> >::Type
444 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)));
446 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class Functor>
447 typename ForEachType<Functor::template TypeEvaluator,
448 tuple<T0, T1, T2, T3, T4> >::Type
449 genericTransformTupleBackend
450 (
const tuple<T0, T1, T2, T3, T4>& t, Functor& f)
452 return typename ForEachType<Functor::template TypeEvaluator,
453 tuple<T0, T1, T2, T3, T4> >::Type
454 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)));
458 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
460 typename ForEachType<Functor::template TypeEvaluator,
461 tuple<T0, T1, T2, T3, T4, T5> >::Type
462 genericTransformTupleBackend
463 (tuple<T0, T1, T2, T3, T4, T5>& t, Functor& f)
465 return typename ForEachType<Functor::template TypeEvaluator,
466 tuple<T0, T1, T2, T3, T4, T5> >::Type
467 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
470 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
472 typename ForEachType<Functor::template TypeEvaluator,
473 tuple<T0, T1, T2, T3, T4, T5> >::Type
474 genericTransformTupleBackend
475 (
const tuple<T0, T1, T2, T3, T4, T5>& t, Functor& f)
477 return typename ForEachType<Functor::template TypeEvaluator,
478 tuple<T0, T1, T2, T3, T4, T5> >::Type
479 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
484 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
485 class T6,
class Functor>
486 typename ForEachType<Functor::template TypeEvaluator,
487 tuple<T0, T1, T2, T3, T4, T5, T6> >::Type
488 genericTransformTupleBackend
489 (tuple<T0, T1, T2, T3, T4, T5, T6>& t, Functor& f)
491 return typename ForEachType<Functor::template TypeEvaluator,
492 tuple<T0, T1, T2, T3, T4, T5, T6> >::Type
493 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
494 f(get<5>(t)), f(get<6>(t)));
496 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
497 class T6,
class Functor>
498 typename ForEachType<Functor::template TypeEvaluator,
499 tuple<T0, T1, T2, T3, T4, T5, T6> >::Type
500 genericTransformTupleBackend
501 (
const tuple<T0, T1, T2, T3, T4, T5, T6>& t, Functor& f)
503 return typename ForEachType<Functor::template TypeEvaluator,
504 tuple<T0, T1, T2, T3, T4, T5, T6> >::Type
505 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
506 f(get<5>(t)), f(get<6>(t)));
510 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
511 class T6,
class T7,
class Functor>
512 typename ForEachType<Functor::template TypeEvaluator,
513 tuple<T0, T1, T2, T3, T4, T5, T6, T7> >::Type
514 genericTransformTupleBackend
515 (tuple<T0, T1, T2, T3, T4, T5, T6, T7>& t, Functor& f)
517 return typename ForEachType<Functor::template TypeEvaluator,
518 tuple<T0, T1, T2, T3, T4, T5, T6, T7> >::Type
519 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
520 f(get<5>(t)), f(get<6>(t)), f(get<7>(t)));
522 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
523 class T6,
class T7,
class Functor>
524 typename ForEachType<Functor::template TypeEvaluator,
525 tuple<T0, T1, T2, T3, T4, T5, T6, T7> >::Type
526 genericTransformTupleBackend
527 (
const tuple<T0, T1, T2, T3, T4, T5, T6, T7>& t, Functor& f)
529 return typename ForEachType<Functor::template TypeEvaluator,
530 tuple<T0, T1, T2, T3, T4, T5, T6, T7> >::Type
531 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
532 f(get<5>(t)), f(get<6>(t)), f(get<7>(t)));
536 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
537 class T6,
class T7,
class T8,
class Functor>
538 typename ForEachType<Functor::template TypeEvaluator,
539 tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >::Type
540 genericTransformTupleBackend
541 (tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8>& t, Functor& f)
543 return typename ForEachType<Functor::template TypeEvaluator,
544 tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >::Type
545 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
546 f(get<5>(t)), f(get<6>(t)), f(get<7>(t)), f(get<8>(t)));
548 template<
class T0,
class T1,
class T2,
class T3,
class T4,
class T5,
549 class T6,
class T7,
class T8,
class Functor>
550 typename ForEachType<Functor::template TypeEvaluator,
551 tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >::Type
552 genericTransformTupleBackend
553 (
const tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8>& t, Functor& f)
555 return typename ForEachType<Functor::template TypeEvaluator,
556 tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >::Type
557 (f(get<0>(t)), f(get<1>(t)), f(get<2>(t)), f(get<3>(t)), f(get<4>(t)),
558 f(get<5>(t)), f(get<6>(t)), f(get<7>(t)), f(get<8>(t)));
630 template<
class Tuple,
class Functor>
633 return genericTransformTupleBackend(t, f);
636 template<
class Tuple,
class Functor>
639 return genericTransformTupleBackend(t, f);
641 template<
class Tuple,
class Functor>
644 return genericTransformTupleBackend(t, f);
646 template<
class Tuple,
class Functor>
649 return genericTransformTupleBackend(t, f);
690 template<
template<
class>
class TE,
class A0 = void,
class A1 = void,
691 class A2 = void,
class A3 = void,
class A4 = void,
class A5 = void,
692 class A6 = void,
class A7 = void,
class A8 = void,
class A9 =
void>
694 A0& a0; A1& a1; A2& a2; A3& a3; A4& a4; A5& a5; A6& a6; A7& a7; A8& a8;
708 A6& a6_, A7& a7_, A8& a8_, A9& a9_)
709 : a0(a0_), a1(a1_), a2(a2_), a3(a3_), a4(a4_), a5(a5_), a6(a6_), a7(a7_),
724 return TE<T>::apply(t, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
781 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
782 class A4,
class A5,
class A6,
class A7,
class A8,
class A9>
783 TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9>
785 A6& a6, A7& a7, A8& a8, A9& a9) {
786 return TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9>
787 (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
792 template<
template<
class>
class TE>
793 struct TransformTupleFunctor<TE>
795 template<
class T>
struct TypeEvaluator :
public TE<T> {};
799 return TE<T>::apply(t);
802 template<
template<
class>
class TE>
803 TransformTupleFunctor<TE>
805 return TransformTupleFunctor<TE>
810 template<
template<
class>
class TE,
class A0>
811 class TransformTupleFunctor<TE, A0>
816 template<
class T>
struct TypeEvaluator :
public TE<T> {};
824 return TE<T>::apply(t, a0);
827 template<
template<
class>
class TE,
class A0>
828 TransformTupleFunctor<TE, A0>
830 return TransformTupleFunctor<TE, A0>
835 template<
template<
class>
class TE,
class A0,
class A1>
836 class TransformTupleFunctor<TE, A0, A1>
841 template<
class T>
struct TypeEvaluator :
public TE<T> {};
849 return TE<T>::apply(t, a0, a1);
852 template<
template<
class>
class TE,
class A0,
class A1>
853 TransformTupleFunctor<TE, A0, A1>
855 return TransformTupleFunctor<TE, A0, A1>
860 template<
template<
class>
class TE,
class A0,
class A1,
class A2>
861 class TransformTupleFunctor<TE, A0, A1, A2>
863 A0& a0; A1& a1; A2& a2;
866 template<
class T>
struct TypeEvaluator :
public TE<T> {};
869 : a0(a0_), a1(a1_), a2(a2_)
874 return TE<T>::apply(t, a0, a1, a2);
877 template<
template<
class>
class TE,
class A0,
class A1,
class A2>
878 TransformTupleFunctor<TE, A0, A1, A2>
880 return TransformTupleFunctor<TE, A0, A1, A2>
885 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3>
886 class TransformTupleFunctor<TE, A0, A1, A2, A3>
888 A0& a0; A1& a1; A2& a2; A3& a3;
891 template<
class T>
struct TypeEvaluator :
public TE<T> {};
894 : a0(a0_), a1(a1_), a2(a2_), a3(a3_)
899 return TE<T>::apply(t, a0, a1, a2, a3);
902 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3>
903 TransformTupleFunctor<TE, A0, A1, A2, A3>
905 return TransformTupleFunctor<TE, A0, A1, A2, A3>
910 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
912 class TransformTupleFunctor<TE, A0, A1, A2, A3, A4>
914 A0& a0; A1& a1; A2& a2; A3& a3; A4& a4;
917 template<
class T>
struct TypeEvaluator :
public TE<T> {};
920 : a0(a0_), a1(a1_), a2(a2_), a3(a3_), a4(a4_)
925 return TE<T>::apply(t, a0, a1, a2, a3, a4);
928 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
930 TransformTupleFunctor<TE, A0, A1, A2, A3, A4>
932 return TransformTupleFunctor<TE, A0, A1, A2, A3, A4>
933 (a0, a1, a2, a3, a4);
937 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
939 class TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5>
941 A0& a0; A1& a1; A2& a2; A3& a3; A4& a4; A5& a5;
944 template<
class T>
struct TypeEvaluator :
public TE<T> {};
947 : a0(a0_), a1(a1_), a2(a2_), a3(a3_), a4(a4_), a5(a5_)
952 return TE<T>::apply(t, a0, a1, a2, a3, a4, a5);
955 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
957 TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5>
959 return TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5>
960 (a0, a1, a2, a3, a4, a5);
964 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
965 class A4,
class A5,
class A6>
966 class TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6>
968 A0& a0; A1& a1; A2& a2; A3& a3; A4& a4; A5& a5; A6& a6;
971 template<
class T>
struct TypeEvaluator :
public TE<T> {};
975 : a0(a0_), a1(a1_), a2(a2_), a3(a3_), a4(a4_), a5(a5_), a6(a6_)
980 return TE<T>::apply(t, a0, a1, a2, a3, a4, a5, a6);
983 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
984 class A4,
class A5,
class A6>
985 TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6>
988 return TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6>
989 (a0, a1, a2, a3, a4, a5, a6);
993 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
994 class A4,
class A5,
class A6,
class A7>
995 class TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7>
997 A0& a0; A1& a1; A2& a2; A3& a3; A4& a4; A5& a5; A6& a6; A7& a7;
1000 template<
class T>
struct TypeEvaluator :
public TE<T> {};
1004 : a0(a0_), a1(a1_), a2(a2_), a3(a3_), a4(a4_), a5(a5_), a6(a6_), a7(a7_)
1008 typename TE<T>::Type
operator()(T& t)
const {
1009 return TE<T>::apply(t, a0, a1, a2, a3, a4, a5, a6, a7);
1012 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
1013 class A4,
class A5,
class A6,
class A7>
1014 TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7>
1017 return TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7>
1018 (a0, a1, a2, a3, a4, a5, a6, a7);
1022 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
1023 class A4,
class A5,
class A6,
class A7,
class A8>
1024 class TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7, A8>
1026 A0& a0; A1& a1; A2& a2; A3& a3; A4& a4; A5& a5; A6& a6; A7& a7; A8& a8;
1029 template<
class T>
struct TypeEvaluator :
public TE<T> {};
1032 A6& a6_, A7& a7_, A8& a8_)
1033 : a0(a0_), a1(a1_), a2(a2_), a3(a3_), a4(a4_), a5(a5_), a6(a6_), a7(a7_),
1038 typename TE<T>::Type
operator()(T& t)
const {
1039 return TE<T>::apply(t, a0, a1, a2, a3, a4, a5, a6, a7, a8);
1042 template<
template<
class>
class TE,
class A0,
class A1,
class A2,
class A3,
1043 class A4,
class A5,
class A6,
class A7,
class A8>
1044 TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7, A8>
1046 A6& a6, A7& a7, A8& a8) {
1047 return TransformTupleFunctor<TE, A0, A1, A2, A3, A4, A5, A6, A7, A8>
1048 (a0, a1, a2, a3, a4, a5, a6, a7, a8);
1147 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1148 class A1,
class A2,
class A3,
class A4,
class A5,
class A6,
1149 class A7,
class A8,
class A9>
1150 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1152 A6& a6, A7& a7, A8& a8, A9& a9) {
1155 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3, a4, a5, a6,
1161 template<
template<
class>
class TypeEvaluator,
class Tuple>
1162 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1166 makeTransformTupleFunctor<TypeEvaluator>());
1170 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0>
1171 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1175 makeTransformTupleFunctor<TypeEvaluator>(a0));
1179 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1181 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1185 makeTransformTupleFunctor<TypeEvaluator>(a0, a1));
1189 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1191 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1195 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2));
1199 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1200 class A1,
class A2,
class A3>
1201 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1205 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3));
1209 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1210 class A1,
class A2,
class A3,
class A4>
1211 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1212 transformTuple(Tuple& orig, A0& a0, A1& a1, A2& a2, A3& a3, A4& a4) {
1215 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3, a4));
1219 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1220 class A1,
class A2,
class A3,
class A4,
class A5>
1221 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1222 transformTuple(Tuple& orig, A0& a0, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
1225 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3, a4, a5));
1229 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1230 class A1,
class A2,
class A3,
class A4,
class A5,
class A6>
1231 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1232 transformTuple(Tuple& orig, A0& a0, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5,
1236 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3, a4, a5, a6));
1240 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1241 class A1,
class A2,
class A3,
class A4,
class A5,
class A6,
1243 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1244 transformTuple(Tuple& orig, A0& a0, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5,
1248 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3, a4, a5, a6,
1253 template<
template<
class>
class TypeEvaluator,
class Tuple,
class A0,
1254 class A1,
class A2,
class A3,
class A4,
class A5,
class A6,
1256 typename remove_const<typename ForEachType<TypeEvaluator, Tuple>::Type>::type
1257 transformTuple(Tuple& orig, A0& a0, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5,
1258 A6& a6, A7& a7, A8& a8) {
1261 makeTransformTupleFunctor<TypeEvaluator>(a0, a1, a2, a3, a4, a5, a6,
1279 static Type apply(T& t) {
return t; }
1289 typedef typename remove_reference<T>::type* Type;
1290 static Type apply(T& t) {
return &t; }
1296 typedef typename remove_reference<T>::type* Type;
1297 static Type apply(T& t) {
return &t; }
1302 template<
int i,
typename T1,
typename F>
1305 static inline void visit(F& func, T1& t1)
1307 func.visit(get<tuple_size<T1>::value-i>(t1));
1308 Visitor<i-1,T1,F>::visit(func, t1);
1312 template<
typename T1,
typename F>
1313 struct Visitor<0,T1,F>
1315 static inline void visit(F&, T1&)
1319 template<
int i,
typename T1,
typename T2,
typename F>
1322 static inline void visit(F& func, T1& t1, T2& t2)
1324 func.visit(get<tuple_size<T1>::value-i>(t1), get<tuple_size<T2>::value-i>(t2));
1325 PairVisitor<i-1,T1,T2,F>::visit(func, t1, t2);
1329 template<
typename T1,
typename T2,
typename F>
1330 struct PairVisitor<0,T1,T2,F>
1332 static inline void visit(F&, T1&, T2&)
1371 template <
class TupleType>
1380 template <
class Functor>
1382 Visitor<tuple_size<TupleType>::value,TupleType,Functor>::visit(f, tuple_);
1404 template <
class TupleType1,
class TupleType2>
1417 template <
class Functor>
1419 PairVisitor<tuple_size<TupleType1>::value,TupleType1,TupleType2,Functor>
1420 ::visit(f, tuple1_, tuple2_);
1423 TupleType1& tuple1_;
1424 TupleType2& tuple2_;
1433 template <
int N,
class Tuple>
1435 typedef typename tuple_element<tuple_size<Tuple>::value - N - 1,
1450 template<
typename Tuple>
1452 typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::NonConstType
1455 return Dune::get<tuple_size<Tuple>::value - N - 1>(t);
1458 template<
typename Tuple>
1460 typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::ConstType
1463 return Dune::get<tuple_size<Tuple>::value - N - 1>(t);
1473 template <
class Tuple>
1477 template<
typename P>
void visit(
const P& p) {
delete p; }
1481 static void apply(Tuple& t) {
1482 static Deletor deletor;
1511 template<
class Tuple,
template<
class>
class Predicate, std::size_t start = 0,
1512 std::size_t size = tuple_size<Tuple>::value>
1514 public conditional<Predicate<typename tuple_element<start,
1515 Tuple>::type>::value,
1516 integral_constant<std::size_t, start>,
1517 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
1519 static_assert(tuple_size<Tuple>::value == size,
"The \"size\" "
1520 "template parameter of FirstPredicateIndex is an "
1521 "implementation detail and should never be set "
1526 template<
class Tuple,
template<
class>
class Predicate, std::size_t size>
1530 "types matches the predicate!");
1563 template<
class Tuple,
class T, std::
size_t start = 0>
1576 template<
class Tuple,
class T>
1580 "unspecialized version of PushBackTuple. "
1581 "PushBackTuple needs to be specialized for "
1582 "each possible tuple size. Naturally the number of "
1583 "pre-defined specializations is limited arbitrarily. "
1584 "Maybe you need to raise this limit by defining some "
1585 "more specializations?");
1599 template<
class... TupleArgs,
class T>
1602 typedef typename Dune::tuple<TupleArgs..., T>
type;
1615 template<
class Tuple,
class T>
1619 "unspecialized version of PushFrontTuple. "
1620 "PushFrontTuple needs to be specialized for "
1621 "each possible tuple size. Naturally the number of "
1622 "pre-defined specializations is limited arbitrarily. "
1623 "Maybe you need to raise this limit by defining some "
1624 "more specializations?");
1638 template<
class... TupleArgs,
class T>
1641 typedef typename Dune::tuple<T, TupleArgs...>
type;
1661 template <
class,
class>
class F,
1664 int N=tuple_size<Tuple>::value>
1668 typedef typename tuple_element<N-1, Tuple>
::type Value;
1671 typedef typename F<Accumulated, Value>::type
type;
1685 template <
class,
class>
class F,
1705 template<
class Head,
class Tail>
1722 template<
class TupleTuple>
Finding the index of a certain type in a tuple.
Definition: tupleutility.hh:1518
Helper template to clone the type definition of a tuple with the storage types replaced by a user-def...
Definition: tupleutility.hh:196
ImplementationDefined Type
type of the transformed tuple
Definition: tupleutility.hh:207
Extension of ForEachValue to two tuples...
Definition: tupleutility.hh:1405
void apply(Functor &f)
Definition: tupleutility.hh:1418
ForEachValuePair(TupleType1 &t1, TupleType2 &t2)
Definition: tupleutility.hh:1410
Helper template which implements iteration over all storage elements in a tuple.
Definition: tupleutility.hh:1372
ForEachValue(TupleType &tuple)
Constructor.
Definition: tupleutility.hh:1376
void apply(Functor &f) const
Applies a function object to each storage element of the tuple.
Definition: tupleutility.hh:1381
A helper template that initializes a tuple consisting of pointers to NULL.
Definition: tupleutility.hh:34
static ResultType apply()
generate a zero-initialized tuple
Tuple ResultType
export the type of the tuples
Definition: tupleutility.hh:45
Deletes all objects pointed to in a tuple of pointers.
Definition: tupleutility.hh:1475
Dune namespace.
Definition: alignment.hh:10
TransformTupleFunctor< TE, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9 > makeTransformTupleFunctor(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4, A5 &a5, A6 &a6, A7 &a7, A8 &a8, A9 &a9)
syntactic sugar for creation of TransformTupleFunctor objects
Definition: tupleutility.hh:784
remove_const< typenameForEachType< TypeEvaluator, Tuple >::Type >::type transformTuple(Tuple &orig, A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4, A5 &a5, A6 &a6, A7 &a7, A8 &a8, A9 &a9)
transform a tuple's value according to a user-supplied policy
Definition: tupleutility.hh:1151
ForEachType< Functor::templateTypeEvaluator, Tuple >::Type genericTransformTuple(Tuple &t, Functor &f)
transform a tuple object into another tuple object
Definition: tupleutility.hh:632
TypeEvaluator to turn a type T into a pointer to T
Definition: tupleutility.hh:1288
TypeEvaluator to turn a type T into a reference to T
Definition: tupleutility.hh:1277
Type for reverse element access.
Definition: tupleutility.hh:1434
Reverse element access.
Definition: tupleutility.hh:1448
Find the first occurance of a type in a tuple.
Definition: tupleutility.hh:1566
Flatten a tuple of tuples.
Definition: tupleutility.hh:1724
ReduceTuple< JoinTuples, TupleTuple >::type type
Result of the flatten operation.
Definition: tupleutility.hh:1726
The actual predicate.
Definition: tupleutility.hh:1547
Generator for predicates accepting one particular type.
Definition: tupleutility.hh:1544
Join two tuples.
Definition: tupleutility.hh:1707
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition: tupleutility.hh:1709
Helper template to append a type to a tuple.
Definition: tupleutility.hh:1578
Tuple type
For all specializations this is the type of a tuple with T appended.
Definition: tupleutility.hh:1593
Helper template to prepend a type to a tuple.
Definition: tupleutility.hh:1617
Tuple type
For all specializations this is the type of a tuple with T prepended.
Definition: tupleutility.hh:1632
Seed type
Result of the reduce operation.
Definition: tupleutility.hh:1691
Apply reduce with meta binary function to template.
Definition: tupleutility.hh:1666
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:1671
template mapping a type to std::false_type
Definition: type_traits.hh:59
Fallback implementation of the std::tuple class.
Traits for type conversions and type information.