Go to the documentation of this file.
4 #ifndef DUNE_TUPLE_UTILITY_HH
5 #define DUNE_TUPLE_UTILITY_HH
31 typedef typename std::add_const<T>::type&
ConstType;
39 typedef typename std::add_const<T>::type*
ConstType;
62 template<
class... Args>
68 return ResultType(
static_cast<Args
>(
nullptr)...);
96 template<
template <
class>
class TE,
class T>
99 template<
template <
class>
class TE,
class... Args>
102 typedef std::tuple<typename TE<Args>::Type...>
Type;
106 template<
class Tuple,
class Functor, std::size_t... I>
107 inline auto genericTransformTupleBackendImpl(Tuple& t, Functor& f,
const Std::index_sequence<I...>& )
108 -> std::tuple<decltype(f(std::get<I>(t)))...>
110 return std::tuple<decltype(f(std::get<I>(t)))...>(f(std::get<I>(t))...);
113 template<
class... Args,
class Functor>
114 auto genericTransformTupleBackend(std::tuple<Args...>& t, Functor& f) ->
115 decltype(genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{}))
117 return genericTransformTupleBackendImpl(t, f,Std::index_sequence_for<Args...>{});
120 template<
class... Args,
class Functor>
121 auto genericTransformTupleBackend(
const std::tuple<Args...>& t, Functor& f) ->
122 decltype(genericTransformTupleBackendImpl(t, f, Std::index_sequence_for<Args...>{}))
124 return genericTransformTupleBackendImpl(t, f, Std::index_sequence_for<Args...>{});
166 template<
class Tuple,
class Functor>
168 decltype(genericTransformTupleBackend(t, f))
170 return genericTransformTupleBackend(t, f);
205 template<
template<
class>
class TE,
class... Args>
208 mutable std::tuple<Args&...> tup;
210 template<
class T, std::size_t... I>
211 inline auto apply(T&& t,
const Std::index_sequence<I...>& ) ->
234 template<
template<
class>
class TE,
class... Args>
272 template<
template<
class>
class TypeEvaluator,
class Tuple,
class... Args>
302 typedef typename std::remove_reference<T>::type*
Type;
313 typedef typename std::remove_reference<T>::type*
Type;
320 template<
class Tuple>
323 ForEachValue(Tuple& t) :
327 template<
class Functor>
328 void apply(Functor& f)
const
330 Hybrid::forEach(Std::make_index_sequence<std::tuple_size<Tuple>::value>{},
331 [&](
auto i){f.visit(std::get<i>(t_));});
337 template<
class Tuple1,
class Tuple2>
340 ForEachValuePair(Tuple1& t1, Tuple2& t2) :
345 template<
class Functor>
346 void apply(Functor& f)
348 Hybrid::forEach(Std::make_index_sequence<std::tuple_size<Tuple1>::value>{},
349 [&](
auto i){f.visit(std::get<i>(t1_), std::get<i>(t2_));});
361 template<
int N,
class Tuple>
364 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type
Type;
377 template<
typename Tuple>
381 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
384 template<
typename Tuple>
388 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
395 template<
class Tuple>
398 template<
typename... Ts>
399 static void apply(std::tuple<Ts...>& t)
428 template<
class Tuple,
template<
class>
class Predicate, std::size_t start = 0,
429 std::size_t size = std::tuple_size<Tuple>::value>
431 public std::conditional<Predicate<typename std::tuple_element<start,
432 Tuple>::type>::value,
433 std::integral_constant<std::size_t, start>,
434 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
436 static_assert(std::tuple_size<Tuple>::value == size,
"The \"size\" "
437 "template parameter of FirstPredicateIndex is an "
438 "implementation detail and should never be set "
443 template<
class Tuple,
template<
class>
class Predicate, std::size_t size>
447 "types matches the predicate!");
481 template<
class Tuple,
class T, std::
size_t start = 0>
492 template<
class Tuple,
class T>
495 template<
class... Args,
class T>
498 typedef typename std::tuple<Args..., T>
type;
507 template<
class Tuple,
class T>
510 template<
class... Args,
class T>
513 typedef typename std::tuple<T, Args...>
type;
529 template <
class,
class>
class F,
531 class Seed=std::tuple<>,
532 int N=std::tuple_size<Tuple>::value>
539 typedef typename F<Accumulated, Value>::type
type;
553 template <
class,
class>
class F,
571 template<
class Head,
class Tail>
586 template<
class Tuple>
Find the first occurrence of a type in a std::tuple.
Definition: tupleutility.hh:482
T * ParameterType
Definition: tupleutility.hh:41
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:308
std::add_const< T >::type & ConstType
Definition: tupleutility.hh:31
TransformTupleFunctor< TE, Args... > makeTransformTupleFunctor(Args &&... args)
Definition: tupleutility.hh:235
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
static void apply(std::tuple< Ts... > &t)
Definition: tupleutility.hh:399
auto transformTuple(Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
Definition: tupleutility.hh:273
Generator for predicates accepting one particular type.
Definition: tupleutility.hh:461
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition: tupleutility.hh:97
Reverse element access.
Definition: tupleutility.hh:375
TransformTupleFunctor(Args &&... args)
Definition: tupleutility.hh:222
T & NonConstType
Definition: tupleutility.hh:48
Dune namespace.
Definition: alignedallocator.hh:9
Join two std::tuple's.
Definition: tupleutility.hh:572
Definition: tupleutility.hh:29
auto genericTransformTuple(Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
Definition: tupleutility.hh:167
T & ConstType
Definition: tupleutility.hh:47
T * NonConstType
Definition: tupleutility.hh:40
static Type apply(T &t)
Definition: tupleutility.hh:303
std::tuple_element< std::tuple_size< Tuple >::value - N - 1, Tuple >::type Type
Definition: tupleutility.hh:364
Type for reverse element access.
Definition: tupleutility.hh:362
ReduceTuple< JoinTuples, Tuple >::type type
Result of the flatten operation.
Definition: tupleutility.hh:590
TypeEvaluator to turn a type T into a reference to T
Definition: tupleutility.hh:285
Definition: tupleutility.hh:206
std::add_const< T >::type * ConstType
Definition: tupleutility.hh:39
T & NonConstType
Definition: tupleutility.hh:32
Definition: tupleutility.hh:219
template mapping a type to std::false_type
Definition: type_traits.hh:79
Seed type
Result of the reduce operation.
Definition: tupleutility.hh:559
make_index_sequence< typename Dune::SizeOf< T... >{}> index_sequence_for
Create index_sequence from 0 to sizeof...(T)-1.
Definition: utility.hh:38
std::tuple< Args... > ResultType
Definition: tupleutility.hh:65
std::remove_reference< T >::type * Type
Definition: tupleutility.hh:302
static Type apply(T &t)
Definition: tupleutility.hh:288
A helper template that initializes a std::tuple consisting of pointers to nullptr.
Definition: tupleutility.hh:60
DUNE_DEPRECATED_MSG("Use Dune::filledArray() from <dune/common/filledarray.hh>") std
Create an array and fill it with copies of the provided value.
Definition: array.hh:51
Flatten a std::tuple of std::tuple's.
Definition: tupleutility.hh:587
std::tuple_element< N-1, Tuple >::type Value
Definition: tupleutility.hh:536
Finding the index of a certain type in a std::tuple.
Definition: tupleutility.hh:430
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:539
ReduceTuple< F, Tuple, Seed, N-1 >::type Accumulated
Definition: tupleutility.hh:535
static Type apply(T &t)
Definition: tupleutility.hh:314
T & Type
Definition: tupleutility.hh:287
static TupleAccessTraits< typename AtType< N, Tuple >::Type >::NonConstType get(Tuple &t)
Definition: tupleutility.hh:379
static TupleAccessTraits< typename AtType< N, Tuple >::Type >::ConstType get(const Tuple &t)
Definition: tupleutility.hh:386
T & ParameterType
Definition: tupleutility.hh:49
const typedef std::remove_const< T >::type & ParameterType
Definition: tupleutility.hh:33
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition: tupleutility.hh:575
std::remove_reference< T >::type * Type
Definition: tupleutility.hh:313
std::tuple< typename TE< Args >::Type... > Type
Definition: tupleutility.hh:102
Helper template to append a type to a std::tuple.
Definition: tupleutility.hh:493
Apply reduce with meta binary function to template.
Definition: tupleutility.hh:533
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
The actual predicate.
Definition: tupleutility.hh:465
static ResultType apply()
Definition: tupleutility.hh:66
Deletes all objects pointed to in a std::tuple of pointers.
Definition: tupleutility.hh:396
std::tuple< Args..., T > type
Definition: tupleutility.hh:498
auto operator()(T &&t) -> decltype(this->apply(t, Std::index_sequence_for< Args... >
Definition: tupleutility.hh:227
Helper template to prepend a type to a std::tuple.
Definition: tupleutility.hh:508
TypeEvaluator to turn a type T into a pointer to T
Definition: tupleutility.hh:300
std::tuple< T, Args... > type
Definition: tupleutility.hh:513