4#ifndef DUNE_TUPLE_UTILITY_HH
5#define DUNE_TUPLE_UTILITY_HH
37 template<
class... Args>
43 return ResultType(
static_cast<Args
>(
nullptr)...);
71 template<
template <
class>
class TE,
class T>
74 template<
template <
class>
class TE,
class... Args>
77 typedef std::tuple<typename TE<Args>::Type...>
Type;
81 template<
class Tuple,
class Functor, std::size_t... I>
83 -> std::tuple<decltype(f(std::get<I>(t)))...>
85 return std::tuple<decltype(f(std::get<I>(t)))...>(f(std::get<I>(t))...);
88 template<
class... Args,
class Functor>
89 auto genericTransformTupleBackend(std::tuple<Args...>& t, Functor& f) ->
90 decltype(genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{}))
92 return genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{});
134 template<
class Tuple,
class Functor>
136 decltype(genericTransformTupleBackend(t, f))
138 return genericTransformTupleBackend(t, f);
173 template<
template<
class>
class TE,
class... Args>
176 mutable std::tuple<Args&...> tup;
178 template<
class T, std::size_t... I>
180 decltype(TE<T>::apply(t,std::get<I>(tup)...))
const
182 return TE<T>::apply(t,std::get<I>(tup)...);
202 template<
template<
class>
class TE,
class... Args>
240 template<
template<
class>
class TypeEvaluator,
class Tuple,
class... Args>
270 typedef typename std::remove_reference<T>::type*
Type;
281 typedef typename std::remove_reference<T>::type*
Type;
290 template<
int i,
typename T1,
typename F>
293 static inline void visit(F& func, T1& t1)
295 func.visit(std::get<std::tuple_size<T1>::value-i>(t1));
296 Visitor<i-1,T1,F>::visit(func, t1);
300 template<
typename T1,
typename F>
301 struct Visitor<0,T1,F>
303 static inline void visit(F&, T1&)
307 template<
int i,
typename T1,
typename T2,
typename F>
310 static inline void visit(F& func, T1& t1, T2& t2)
312 func.visit(std::get<std::tuple_size<T1>::value-i>(t1), std::get<std::tuple_size<T2>::value-i>(t2));
313 PairVisitor<i-1,T1,T2,F>::visit(func, t1, t2);
317 template<
typename T1,
typename T2,
typename F>
318 struct PairVisitor<0,T1,T2,F>
320 static inline void visit(F&, T1&, T2&)
368 template<
class Tuple>
380 template<
class Functor>
383 Visitor<std::tuple_size<Tuple>::value,Tuple,Functor>::visit(f, t_);
402 template<
class Tuple1,
class Tuple2>
416 template<
class Functor>
419 PairVisitor<std::tuple_size<Tuple1>::value,Tuple1,Tuple2,Functor>::visit(f, t1_, t2_);
431 template<
int N,
class Tuple>
434 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type
Type;
447 template<
typename Tuple>
451 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
454 template<
typename Tuple>
458 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
468 template<
class Tuple>
483 static Deletor deletor;
511 template<
class Tuple,
template<
class>
class Predicate, std::size_t start = 0,
512 std::size_t size = std::tuple_size<Tuple>::value>
514 public std::conditional<Predicate<typename std::tuple_element<start,
515 Tuple>::type>::value,
516 std::integral_constant<std::size_t, start>,
517 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
519 static_assert(std::tuple_size<Tuple>::value == size,
"The \"size\" "
520 "template parameter of FirstPredicateIndex is an "
521 "implementation detail and should never be set "
526 template<
class Tuple,
template<
class>
class Predicate, std::size_t size>
530 "types matches the predicate!");
564 template<
class Tuple,
class T, std::
size_t start = 0>
575 template<
class Tuple,
class T>
578 template<
class... Args,
class T>
581 typedef typename std::tuple<Args..., T>
type;
590 template<
class Tuple,
class T>
593 template<
class... Args,
class T>
596 typedef typename std::tuple<T, Args...>
type;
612 template <
class,
class>
class F,
614 class Seed=std::tuple<>,
615 int N=tuple_size<Tuple>::value>
622 typedef typename F<Accumulated, Value>::type
type;
636 template <
class,
class>
class F,
654 template<
class Head,
class Tail>
669 template<
class Tuple>
Traits for type conversions and type information.
Fallback implementation of the std::tuple class.
static void apply(Tuple &t)
Definition tupleutility.hh:481
ForEachValuePair(Tuple1 &t1, Tuple2 &t2)
Definition tupleutility.hh:409
auto transformTuple(Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
Definition tupleutility.hh:241
ReduceTuple< F, Tuple, Seed, N-1 >::type Accumulated
Definition tupleutility.hh:618
Seed type
Result of the reduce operation.
Definition tupleutility.hh:642
std::remove_reference< T >::type * Type
Definition tupleutility.hh:270
static Type apply(T &t)
Definition tupleutility.hh:256
static ResultType apply()
Definition tupleutility.hh:41
std::tuple< Args... > ResultType
Definition tupleutility.hh:40
std::remove_reference< T >::type * Type
Definition tupleutility.hh:281
TransformTupleFunctor(Args &&... args)
Definition tupleutility.hh:190
std::tuple_element< std::tuple_size< Tuple >::value-N-1, Tuple >::type Type
Definition tupleutility.hh:434
static Type apply(T &t)
Definition tupleutility.hh:282
static TupleAccessTraits< typenameAtType< N, Tuple >::Type >::ConstType get(const Tuple &t)
Definition tupleutility.hh:456
T & Type
Definition tupleutility.hh:255
static TupleAccessTraits< typenameAtType< N, Tuple >::Type >::NonConstType get(Tuple &t)
Definition tupleutility.hh:449
void apply(Functor &f)
Definition tupleutility.hh:417
std::tuple< Args..., T > type
Definition tupleutility.hh:581
std::tuple_element< N-1, Tuple >::type Value
Definition tupleutility.hh:619
std::tuple< T, Args... > type
Definition tupleutility.hh:596
ReduceTuple< JoinTuples, Tuple >::type type
Result of the flatten operation.
Definition tupleutility.hh:673
static Type apply(T &t)
Definition tupleutility.hh:271
void visit(const P &p)
Definition tupleutility.hh:474
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition tupleutility.hh:622
ForEachValue(Tuple &t)
Constructor.
Definition tupleutility.hh:374
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition tupleutility.hh:658
void apply(Functor &f) const
Applies a function object to each storage element of the std::tuple.
Definition tupleutility.hh:381
std::tuple< typename TE< Args >::Type... > Type
Definition tupleutility.hh:77
auto genericTransformTuple(Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
Definition tupleutility.hh:135
auto operator()(T &&t) -> decltype(this->apply(t, Std::index_sequence_for< Args... >{})) const
Definition tupleutility.hh:195
TransformTupleFunctor< TE, Args... > makeTransformTupleFunctor(Args &&... args)
Definition tupleutility.hh:203
Dune namespace.
Definition alignment.hh:11
integer_sequence< std::size_t, Ints... > index_sequence
std::index_sequence as introduced in C++14
Definition utility.hh:54
make_index_sequence< impl::_get_pack_length< T... >{}> index_sequence_for
Definition utility.hh:101
template mapping a type to std::false_type
Definition type_traits.hh:59
A helper template that initializes a std::tuple consisting of pointers to nullptr.
Definition tupleutility.hh:35
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition tupleutility.hh:72
Definition tupleutility.hh:175
Definition tupleutility.hh:188
TypeEvaluator to turn a type T into a reference to T
Definition tupleutility.hh:254
TypeEvaluator to turn a type T into a pointer to T
Definition tupleutility.hh:269
Helper template which implements iteration over all storage elements in a std::tuple.
Definition tupleutility.hh:370
Extension of ForEachValue to two std::tuple's.
Definition tupleutility.hh:404
Type for reverse element access.
Definition tupleutility.hh:433
Reverse element access.
Definition tupleutility.hh:446
Deletes all objects pointed to in a std::tuple of pointers.
Definition tupleutility.hh:470
Finding the index of a certain type in a std::tuple.
Definition tupleutility.hh:518
Generator for predicates accepting one particular type.
Definition tupleutility.hh:545
The actual predicate.
Definition tupleutility.hh:548
Find the first occurrence of a type in a std::tuple.
Definition tupleutility.hh:567
Helper template to append a type to a std::tuple.
Definition tupleutility.hh:576
Helper template to prepend a type to a std::tuple.
Definition tupleutility.hh:591
Apply reduce with meta binary function to template.
Definition tupleutility.hh:617
Join two std::tuple's.
Definition tupleutility.hh:656
Flatten a std::tuple of std::tuple's.
Definition tupleutility.hh:671