4 #ifndef DUNE_TUPLE_UTILITY_HH
5 #define DUNE_TUPLE_UTILITY_HH
39 template<
class F,
class ArgTuple,
class I, I... i>
40 decltype(
auto)
applyPartial(F&& f, ArgTuple&& args, std::integer_sequence<I, i...> )
42 return f(std::get<i>(args)...);
48 typedef typename std::add_const<T>::type&
ConstType;
56 typedef typename std::add_const<T>::type*
ConstType;
79 template<
class... Args>
85 return ResultType(
static_cast<Args
>(
nullptr)...);
113 template<
template <
class>
class TE,
class T>
116 template<
template <
class>
class TE,
class... Args>
119 typedef std::tuple<typename TE<Args>::Type...>
Type;
123 template<
class Tuple,
class Functor, std::size_t... I>
124 inline auto genericTransformTupleBackendImpl(Tuple& t, Functor& f,
const Std::index_sequence<I...>& )
125 -> std::tuple<decltype(f(std::get<I>(t)))...>
127 return std::tuple<decltype(f(std::get<I>(t)))...>(f(std::get<I>(t))...);
130 template<
class... Args,
class Functor>
131 auto genericTransformTupleBackend(std::tuple<Args...>& t, Functor& f) ->
132 decltype(genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{}))
134 return genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{});
137 template<
class... Args,
class Functor>
138 auto genericTransformTupleBackend(
const std::tuple<Args...>& t, Functor& f) ->
139 decltype(genericTransformTupleBackendImpl(t, f, Std::index_sequence_for<Args...>{}))
141 return genericTransformTupleBackendImpl(t, f, Std::index_sequence_for<Args...>{});
183 template<
class Tuple,
class Functor>
185 decltype(genericTransformTupleBackend(t, f))
187 return genericTransformTupleBackend(t, f);
222 template<
template<
class>
class TE,
class... Args>
225 mutable std::tuple<Args&...> tup;
227 template<
class T, std::size_t... I>
228 inline auto apply(T&& t,
const Std::index_sequence<I...>& ) ->
251 template<
template<
class>
class TE,
class... Args>
289 template<
template<
class>
class TypeEvaluator,
class Tuple,
class... Args>
319 typedef typename std::remove_reference<T>::type*
Type;
330 typedef typename std::remove_reference<T>::type*
Type;
342 template<
int N,
class Tuple>
345 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type
Type;
358 template<
typename Tuple>
362 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
365 template<
typename Tuple>
369 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
376 template<
class Tuple>
379 template<
typename... Ts>
380 static void apply(std::tuple<Ts...>& t)
409 template<
class Tuple,
template<
class>
class Predicate, std::size_t start = 0,
410 std::size_t size = std::tuple_size<Tuple>::value>
412 public std::conditional<Predicate<typename std::tuple_element<start,
413 Tuple>::type>::value,
414 std::integral_constant<std::size_t, start>,
415 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
417 static_assert(std::tuple_size<Tuple>::value == size,
"The \"size\" "
418 "template parameter of FirstPredicateIndex is an "
419 "implementation detail and should never be set "
424 template<
class Tuple,
template<
class>
class Predicate, std::size_t size>
428 "types matches the predicate!");
462 template<
class Tuple,
class T, std::
size_t start = 0>
473 template<
class Tuple,
class T>
476 template<
class... Args,
class T>
479 typedef typename std::tuple<Args..., T>
type;
488 template<
class Tuple,
class T>
491 template<
class... Args,
class T>
494 typedef typename std::tuple<T, Args...>
type;
510 template <
class,
class>
class F,
512 class Seed=std::tuple<>,
513 int N=std::tuple_size<Tuple>::value>
520 typedef typename F<Accumulated, Value>::type
type;
534 template <
class,
class>
class F,
552 template<
class Head,
class Tail>
567 template<
class Tuple>
std::add_const< T >::type & ConstType
Definition: tupleutility.hh:48
static void apply(std::tuple< Ts... > &t)
Definition: tupleutility.hh:380
T * ParameterType
Definition: tupleutility.hh:58
auto transformTuple(Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
Definition: tupleutility.hh:290
static TupleAccessTraits< typename AtType< N, Tuple >::Type >::NonConstType get(Tuple &t)
Definition: tupleutility.hh:360
T & ConstType
Definition: tupleutility.hh:64
T * NonConstType
Definition: tupleutility.hh:57
Seed type
Result of the reduce operation.
Definition: tupleutility.hh:540
std::remove_reference< T >::type * Type
Definition: tupleutility.hh:319
static Type apply(T &t)
Definition: tupleutility.hh:305
static ResultType apply()
Definition: tupleutility.hh:83
std::tuple< Args... > ResultType
Definition: tupleutility.hh:82
std::remove_reference< T >::type * Type
Definition: tupleutility.hh:330
TransformTupleFunctor(Args &&... args)
Definition: tupleutility.hh:239
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition: tupleutility.hh:556
static Type apply(T &t)
Definition: tupleutility.hh:331
ReduceTuple< F, Tuple, Seed, N-1 >::type Accumulated
Definition: tupleutility.hh:516
T & NonConstType
Definition: tupleutility.hh:65
std::tuple_element< N-1, Tuple >::type Value
Definition: tupleutility.hh:517
std::tuple_element< std::tuple_size< Tuple >::value - N - 1, Tuple >::type Type
Definition: tupleutility.hh:345
T & NonConstType
Definition: tupleutility.hh:49
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:520
static TupleAccessTraits< typename AtType< N, Tuple >::Type >::ConstType get(const Tuple &t)
Definition: tupleutility.hh:367
T & Type
Definition: tupleutility.hh:304
ReduceTuple< JoinTuples, Tuple >::type type
Result of the flatten operation.
Definition: tupleutility.hh:571
TransformTupleFunctor< TE, Args... > makeTransformTupleFunctor(Args &&... args)
Definition: tupleutility.hh:252
std::tuple< Args..., T > type
Definition: tupleutility.hh:479
std::tuple< T, Args... > type
Definition: tupleutility.hh:494
static Type apply(T &t)
Definition: tupleutility.hh:320
std::tuple< typename TE< Args >::Type... > Type
Definition: tupleutility.hh:119
auto genericTransformTuple(Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
Definition: tupleutility.hh:184
decltype(auto) applyPartial(F &&f, ArgTuple &&args, std::integer_sequence< I, i... >)
Apply function with arguments from a given tuple.
Definition: tupleutility.hh:40
T & ParameterType
Definition: tupleutility.hh:66
const std::remove_const< T >::type & ParameterType
Definition: tupleutility.hh:50
std::add_const< T >::type * ConstType
Definition: tupleutility.hh:56
auto operator()(T &&t) -> decltype(this->apply(t, Std::index_sequence_for< Args... >{})) const
Definition: tupleutility.hh:244
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:267
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:46
Dune namespace.
Definition: alignedallocator.hh:14
make_index_sequence< typename Dune::SizeOf< T... >{}> index_sequence_for
Create index_sequence from 0 to sizeof...(T)-1.
Definition: utility.hh:38
template mapping a type to std::false_type
Definition: type_traits.hh:79
Definition: tupleutility.hh:47
A helper template that initializes a std::tuple consisting of pointers to nullptr.
Definition: tupleutility.hh:77
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition: tupleutility.hh:114
Definition: tupleutility.hh:224
Definition: tupleutility.hh:237
TypeEvaluator to turn a type T into a reference to T
Definition: tupleutility.hh:303
TypeEvaluator to turn a type T into a pointer to T
Definition: tupleutility.hh:318
Type for reverse element access.
Definition: tupleutility.hh:344
Reverse element access.
Definition: tupleutility.hh:357
Deletes all objects pointed to in a std::tuple of pointers.
Definition: tupleutility.hh:378
Finding the index of a certain type in a std::tuple.
Definition: tupleutility.hh:416
Generator for predicates accepting one particular type.
Definition: tupleutility.hh:443
The actual predicate.
Definition: tupleutility.hh:446
Find the first occurrence of a type in a std::tuple.
Definition: tupleutility.hh:465
Helper template to append a type to a std::tuple.
Definition: tupleutility.hh:474
Helper template to prepend a type to a std::tuple.
Definition: tupleutility.hh:489
Apply reduce with meta binary function to template.
Definition: tupleutility.hh:515
Join two std::tuple's.
Definition: tupleutility.hh:554
Flatten a std::tuple of std::tuple's.
Definition: tupleutility.hh:569