4 #ifndef DUNE_TUPLE_UTILITY_HH 5 #define DUNE_TUPLE_UTILITY_HH 30 typedef typename std::add_const<T>::type&
ConstType;
38 typedef typename std::add_const<T>::type*
ConstType;
61 template<
class... Args>
67 return ResultType(static_cast<Args>(
nullptr)...);
95 template<
template <
class>
class TE,
class T>
98 template<
template <
class>
class TE,
class... Args>
101 typedef std::tuple<typename TE<Args>::Type...>
Type;
105 template<
class Tuple,
class Functor, std::size_t... I>
106 inline auto genericTransformTupleBackendImpl(Tuple& t, Functor& f,
const Std::index_sequence<I...>& )
107 -> std::tuple<decltype(f(std::get<I>(t)))...>
109 return std::tuple<decltype(f(std::get<I>(t)))...>(f(std::get<I>(t))...);
112 template<
class... Args,
class Functor>
113 auto genericTransformTupleBackend(std::tuple<Args...>& t, Functor& f) ->
114 decltype(genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{}))
116 return genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{});
119 template<
class... Args,
class Functor>
120 auto genericTransformTupleBackend(
const std::tuple<Args...>& t, Functor& f) ->
121 decltype(genericTransformTupleBackendImpl(t, f, Std::index_sequence_for<Args...>{}))
123 return genericTransformTupleBackendImpl(t, f, Std::index_sequence_for<Args...>{});
165 template<
class Tuple,
class Functor>
167 decltype(genericTransformTupleBackend(t, f))
169 return genericTransformTupleBackend(t, f);
204 template<
template<
class>
class TE,
class... Args>
207 mutable std::tuple<Args&...> tup;
209 template<
class T, std::size_t... I>
210 inline auto apply(T&& t,
const Std::index_sequence<I...>& ) ->
233 template<
template<
class>
class TE,
class... Args>
271 template<
template<
class>
class TypeEvaluator,
class Tuple,
class... Args>
301 typedef typename std::remove_reference<T>::type*
Type;
312 typedef typename std::remove_reference<T>::type*
Type;
362 template<
class Tuple>
374 template<
class Functor>
377 Hybrid::forEach(Std::make_index_sequence<std::tuple_size<Tuple>::value>{},
378 [&](
auto i){f.visit(std::get<i>(t_));});
397 template<
class Tuple1,
class Tuple2>
411 template<
class Functor>
414 Hybrid::forEach(Std::make_index_sequence<std::tuple_size<Tuple1>::value>{},
415 [&](
auto i){f.visit(std::get<i>(t1_), std::get<i>(t2_));});
427 template<
int N,
class Tuple>
430 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type
Type;
443 template<
typename Tuple>
447 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
450 template<
typename Tuple>
454 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
461 template<
class Tuple>
464 template<
typename... Ts>
465 static void apply(std::tuple<Ts...>& t)
494 template<
class Tuple,
template<
class>
class Predicate, std::size_t start = 0,
495 std::size_t
size = std::tuple_size<Tuple>::value>
497 public std::conditional<Predicate<typename std::tuple_element<start,
498 Tuple>::type>::value,
499 std::integral_constant<std::size_t, start>,
500 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
502 static_assert(std::tuple_size<Tuple>::value ==
size,
"The \"size\" " 503 "template parameter of FirstPredicateIndex is an " 504 "implementation detail and should never be set " 509 template<
class Tuple,
template<
class>
class Predicate, std::size_t
size>
513 "types matches the predicate!");
547 template<
class Tuple,
class T, std::
size_t start = 0>
558 template<
class Tuple,
class T>
561 template<
class... Args,
class T>
564 typedef typename std::tuple<Args..., T>
type;
573 template<
class Tuple,
class T>
576 template<
class... Args,
class T>
579 typedef typename std::tuple<T, Args...>
type;
595 template <
class,
class>
class F,
597 class Seed=std::tuple<>,
598 int N=std::tuple_size<Tuple>::value>
605 typedef typename F<Accumulated, Value>::type
type;
619 template <
class,
class>
class F,
637 template<
class Head,
class Tail>
652 template<
class Tuple>
Join two std::tuple's.
Definition: tupleutility.hh:638
std::tuple< T, Args... > type
Definition: tupleutility.hh:579
const std::remove_const< T >::type & ParameterType
Definition: tupleutility.hh:32
T * NonConstType
Definition: tupleutility.hh:39
static Type apply(T &t)
Definition: tupleutility.hh:287
make_index_sequence< typename Dune::SizeOf< T... >{}> index_sequence_for
Create index_sequence from 0 to sizeof...(T)-1.
Definition: utility.hh:38
auto operator()(T &&t) -> decltype(this->apply(t, Std::index_sequence_for< Args... >
Definition: tupleutility.hh:226
static Type apply(T &t)
Definition: tupleutility.hh:313
std::tuple_element< std::tuple_size< Tuple >::value - N - 1, Tuple >::type Type
Definition: tupleutility.hh:430
TypeEvaluator to turn a type T into a reference to T
Definition: tupleutility.hh:284
static void apply(std::tuple< Ts... > &t)
Definition: tupleutility.hh:465
auto genericTransformTuple(Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
Definition: tupleutility.hh:166
TransformTupleFunctor(Args &&... args)
Definition: tupleutility.hh:221
ForEachValue(Tuple &t)
Constructor.
Definition: tupleutility.hh:368
T & ParameterType
Definition: tupleutility.hh:48
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:54
Type for reverse element access.
Definition: tupleutility.hh:428
std::tuple_element< N-1, Tuple >::type Value
Definition: tupleutility.hh:602
template mapping a type to std::false_type
Definition: type_traits.hh:63
std::tuple< Args..., T > type
Definition: tupleutility.hh:564
The actual predicate.
Definition: tupleutility.hh:531
Seed type
Result of the reduce operation.
Definition: tupleutility.hh:625
Deletes all objects pointed to in a std::tuple of pointers.
Definition: tupleutility.hh:462
void apply(Functor &f) const
Applies a function object to each storage element of the std::tuple.
Definition: tupleutility.hh:375
Dune namespace.
Definition: alignment.hh:10
std::add_const< T >::type & ConstType
Definition: tupleutility.hh:30
static ResultType apply()
Definition: tupleutility.hh:65
void apply(Functor &f)
Definition: tupleutility.hh:412
Definition: tupleutility.hh:218
Helper template to append a type to a std::tuple.
Definition: tupleutility.hh:559
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition: tupleutility.hh:96
std::remove_reference< T >::type * Type
Definition: tupleutility.hh:301
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:605
Extension of ForEachValue to two std::tuple's.
Definition: tupleutility.hh:398
std::tuple< Args... > ResultType
Definition: tupleutility.hh:64
T & Type
Definition: tupleutility.hh:286
TypeEvaluator to turn a type T into a pointer to T
Definition: tupleutility.hh:299
Definition: tupleutility.hh:205
T & NonConstType
Definition: tupleutility.hh:47
auto transformTuple(Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
Definition: tupleutility.hh:272
Generator for predicates accepting one particular type.
Definition: tupleutility.hh:527
Reverse element access.
Definition: tupleutility.hh:441
Helper template which implements iteration over all storage elements in a std::tuple.
Definition: tupleutility.hh:363
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition: tupleutility.hh:641
ForEachValuePair(Tuple1 &t1, Tuple2 &t2)
Definition: tupleutility.hh:404
std::remove_reference< T >::type * Type
Definition: tupleutility.hh:312
Helper template to prepend a type to a std::tuple.
Definition: tupleutility.hh:574
Find the first occurrence of a type in a std::tuple.
Definition: tupleutility.hh:548
Finding the index of a certain type in a std::tuple.
Definition: tupleutility.hh:496
T & ConstType
Definition: tupleutility.hh:46
ReduceTuple< F, Tuple, Seed, N-1 >::type Accumulated
Definition: tupleutility.hh:601
A helper template that initializes a std::tuple consisting of pointers to nullptr.
Definition: tupleutility.hh:59
Flatten a std::tuple of std::tuple's.
Definition: tupleutility.hh:653
Definition: tupleutility.hh:28
T * ParameterType
Definition: tupleutility.hh:40
constexpr auto size(const Dune::FieldVector< T, i > *, const PriorityTag< 5 > &) -> decltype(std::integral_constant< std::size_t, i >())
Definition: hybridutilities.hh:22
Apply reduce with meta binary function to template.
Definition: tupleutility.hh:599
std::tuple< typename TE< Args >::Type... > Type
Definition: tupleutility.hh:101
std::add_const< T >::type * ConstType
Definition: tupleutility.hh:38
T & NonConstType
Definition: tupleutility.hh:31
static Type apply(T &t)
Definition: tupleutility.hh:302
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:314
TransformTupleFunctor< TE, Args... > makeTransformTupleFunctor(Args &&... args)
Definition: tupleutility.hh:234
ReduceTuple< JoinTuples, Tuple >::type type
Result of the flatten operation.
Definition: tupleutility.hh:656