dune-common  2.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Files | Classes | Typedefs | Functions | Variables
Tuple Utilities

Utility classes which can be used with std::tuple. More...

Files

file  tupleutility.hh
 Contains utility classes which can be used with std::tuple.
 

Classes

struct  Dune::TupleAccessTraits< T >
 
struct  Dune::TupleAccessTraits< T * >
 
struct  Dune::TupleAccessTraits< T & >
 
struct  Dune::NullPointerInitialiser< T >
 A helper template that initializes a std::tuple consisting of pointers to nullptr. More...
 
struct  Dune::NullPointerInitialiser< std::tuple< Args...> >
 
struct  Dune::ForEachType< TE, T >
 Helper template to clone the type definition of a std::tuple with the storage types replaced by a user-defined rule. More...
 
struct  Dune::ForEachType< TE, std::tuple< Args...> >
 
class  Dune::TransformTupleFunctor< TE, Args >
 
struct  Dune::TransformTupleFunctor< TE, Args >::TypeEvaluator< T >
 
struct  Dune::AddRefTypeEvaluator< T >
 TypeEvaluator to turn a type T into a reference to T More...
 
struct  Dune::AddPtrTypeEvaluator< T >
 TypeEvaluator to turn a type T into a pointer to T More...
 
struct  Dune::AddPtrTypeEvaluator< T & >
 
class  Dune::ForEachValue< Tuple >
 Helper template which implements iteration over all storage elements in a std::tuple. More...
 
class  Dune::ForEachValuePair< Tuple1, Tuple2 >
 Extension of ForEachValue to two std::tuple's. More...
 
struct  Dune::AtType< N, Tuple >
 Type for reverse element access. More...
 
struct  Dune::At< N >
 Reverse element access. More...
 
struct  Dune::PointerPairDeletor< Tuple >
 Deletes all objects pointed to in a std::tuple of pointers. More...
 
class  Dune::FirstPredicateIndex< Tuple, Predicate, start, size >
 Finding the index of a certain type in a std::tuple. More...
 
struct  Dune::IsType< T >
 Generator for predicates accepting one particular type. More...
 
struct  Dune::IsType< T >::Predicate< U >
 The actual predicate. More...
 
struct  Dune::FirstTypeIndex< Tuple, T, start >
 Find the first occurrence of a type in a std::tuple. More...
 
struct  Dune::PushBackTuple< Tuple, T >
 Helper template to append a type to a std::tuple. More...
 
struct  Dune::PushBackTuple< typename std::tuple< Args...>, T >
 
struct  Dune::PushFrontTuple< Tuple, T >
 Helper template to prepend a type to a std::tuple. More...
 
struct  Dune::PushFrontTuple< typename std::tuple< Args...>, T >
 
struct  Dune::ReduceTuple< F, Tuple, Seed, N >
 Apply reduce with meta binary function to template. More...
 
struct  Dune::ReduceTuple< F, Tuple, Seed, 0 >
 Apply reduce with meta binary function to template. More...
 
struct  Dune::JoinTuples< Head, Tail >
 Join two std::tuple's. More...
 
struct  Dune::FlattenTuple< Tuple >
 Flatten a std::tuple of std::tuple's. More...
 

Typedefs

typedef std::add_const< T >::type & Dune::TupleAccessTraits< T >::ConstType
 
typedef T & Dune::TupleAccessTraits< T >::NonConstType
 
typedef const
std::remove_const< T >::type & 
Dune::TupleAccessTraits< T >::ParameterType
 
typedef std::add_const< T >::type * Dune::TupleAccessTraits< T * >::ConstType
 
typedef T * Dune::TupleAccessTraits< T * >::NonConstType
 
typedef T * Dune::TupleAccessTraits< T * >::ParameterType
 
typedef T & Dune::TupleAccessTraits< T & >::ConstType
 
typedef T & Dune::TupleAccessTraits< T & >::NonConstType
 
typedef T & Dune::TupleAccessTraits< T & >::ParameterType
 
typedef std::tuple< Args...> Dune::NullPointerInitialiser< std::tuple< Args...> >::ResultType
 
typedef std::tuple< typename
TE< Args >::Type...> 
Dune::ForEachType< TE, std::tuple< Args...> >::Type
 
typedef T & Dune::AddRefTypeEvaluator< T >::Type
 
typedef std::remove_reference
< T >::type * 
Dune::AddPtrTypeEvaluator< T >::Type
 
typedef std::remove_reference
< T >::type * 
Dune::AddPtrTypeEvaluator< T & >::Type
 
typedef std::tuple_element
< std::tuple_size< Tuple >
::value-N-1, Tuple >::type 
Dune::AtType< N, Tuple >::Type
 
typedef std::tuple< Args..., T > Dune::PushBackTuple< typename std::tuple< Args...>, T >::type
 
typedef std::tuple< T, Args...> Dune::PushFrontTuple< typename std::tuple< Args...>, T >::type
 
typedef ReduceTuple< F, Tuple,
Seed, N-1 >::type 
Dune::ReduceTuple< F, Tuple, Seed, N >::Accumulated
 
typedef std::tuple_element< N-1,
Tuple >::type 
Dune::ReduceTuple< F, Tuple, Seed, N >::Value
 
typedef F< Accumulated, Value >
::type 
Dune::ReduceTuple< F, Tuple, Seed, N >::type
 Result of the reduce operation. More...
 
typedef Seed Dune::ReduceTuple< F, Tuple, Seed, 0 >::type
 Result of the reduce operation. More...
 
typedef ReduceTuple
< PushBackTuple, Tail, Head >
::type 
Dune::JoinTuples< Head, Tail >::type
 Result of the join operation. More...
 
typedef ReduceTuple
< JoinTuples, Tuple >::type 
Dune::FlattenTuple< Tuple >::type
 Result of the flatten operation. More...
 

Functions

static ResultType Dune::NullPointerInitialiser< std::tuple< Args...> >::apply ()
 
template<class Tuple , class Functor >
auto Dune::genericTransformTuple (Tuple &&t, Functor &&f) ->
 
 Dune::TransformTupleFunctor< TE, Args >::TransformTupleFunctor (Args &&...args)
 
template<class T >
auto Dune::TransformTupleFunctor< TE, Args >::operator() (T &&t) -> decltype(this->apply(t, Std::index_sequence_for< Args...>
 
template<template< class > class TE, class... Args>
TransformTupleFunctor< TE, Args...> Dune::makeTransformTupleFunctor (Args &&...args)
 
template<template< class > class TypeEvaluator, class Tuple , class... Args>
auto Dune::transformTuple (Tuple &&orig, Args &&...args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
 
static Type Dune::AddRefTypeEvaluator< T >::apply (T &t)
 
static Type Dune::AddPtrTypeEvaluator< T >::apply (T &t)
 
static Type Dune::AddPtrTypeEvaluator< T & >::apply (T &t)
 
 Dune::ForEachValue< Tuple >::ForEachValue (Tuple &t)
 Constructor. More...
 
template<class Functor >
void Dune::ForEachValue< Tuple >::apply (Functor &f) const
 Applies a function object to each storage element of the std::tuple. More...
 
 Dune::ForEachValuePair< Tuple1, Tuple2 >::ForEachValuePair (Tuple1 &t1, Tuple2 &t2)
 
template<class Functor >
void Dune::ForEachValuePair< Tuple1, Tuple2 >::apply (Functor &f)
 
template<typename Tuple >
static TupleAccessTraits
< typename AtType< N, Tuple >
::Type >::NonConstType 
Dune::At< N >::get (Tuple &t)
 
template<typename Tuple >
static TupleAccessTraits
< typename AtType< N, Tuple >
::Type >::ConstType 
Dune::At< N >::get (const Tuple &t)
 
template<typename... Ts>
static void Dune::PointerPairDeletor< Tuple >::apply (std::tuple< Ts...> &t)
 

Variables

 Dune::TransformTupleFunctor< TE, Args >::const
 

Detailed Description

Utility classes which can be used with std::tuple.

Typedef Documentation

template<template< class, class > class F, class Tuple, class Seed = std::tuple<>, int N = std::tuple_size<Tuple>::value>
typedef ReduceTuple<F, Tuple, Seed, N-1>::type Dune::ReduceTuple< F, Tuple, Seed, N >::Accumulated
template<class T >
typedef std::add_const<T>::type& Dune::TupleAccessTraits< T >::ConstType
template<class T >
typedef std::add_const<T>::type* Dune::TupleAccessTraits< T * >::ConstType
template<class T >
typedef T& Dune::TupleAccessTraits< T & >::ConstType
template<class T >
typedef T& Dune::TupleAccessTraits< T >::NonConstType
template<class T >
typedef T* Dune::TupleAccessTraits< T * >::NonConstType
template<class T >
typedef T& Dune::TupleAccessTraits< T & >::NonConstType
template<class T >
typedef const std::remove_const<T>::type& Dune::TupleAccessTraits< T >::ParameterType
template<class T >
typedef T* Dune::TupleAccessTraits< T * >::ParameterType
template<class T >
typedef T& Dune::TupleAccessTraits< T & >::ParameterType
template<class... Args>
typedef std::tuple<Args...> Dune::NullPointerInitialiser< std::tuple< Args...> >::ResultType
template<template< class > class TE, class... Args>
typedef std::tuple<typename TE<Args>::Type...> Dune::ForEachType< TE, std::tuple< Args...> >::Type
template<class T >
typedef T& Dune::AddRefTypeEvaluator< T >::Type
template<class T >
typedef std::remove_reference<T>::type* Dune::AddPtrTypeEvaluator< T >::Type
template<class T >
typedef std::remove_reference<T>::type* Dune::AddPtrTypeEvaluator< T & >::Type
template<int N, class Tuple >
typedef std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type Dune::AtType< N, Tuple >::Type
template<class... Args, class T >
typedef std::tuple<Args..., T> Dune::PushBackTuple< typename std::tuple< Args...>, T >::type
template<class... Args, class T >
typedef std::tuple<T, Args...> Dune::PushFrontTuple< typename std::tuple< Args...>, T >::type
template<template< class, class > class F, class Tuple, class Seed = std::tuple<>, int N = std::tuple_size<Tuple>::value>
typedef F<Accumulated, Value>::type Dune::ReduceTuple< F, Tuple, Seed, N >::type

Result of the reduce operation.

template<template< class, class > class F, class Tuple , class Seed >
typedef Seed Dune::ReduceTuple< F, Tuple, Seed, 0 >::type

Result of the reduce operation.

template<class Head, class Tail>
typedef ReduceTuple<PushBackTuple, Tail, Head>::type Dune::JoinTuples< Head, Tail >::type

Result of the join operation.

template<class Tuple >
typedef ReduceTuple<JoinTuples, Tuple>::type Dune::FlattenTuple< Tuple >::type

Result of the flatten operation.

template<template< class, class > class F, class Tuple, class Seed = std::tuple<>, int N = std::tuple_size<Tuple>::value>
typedef std::tuple_element<N-1, Tuple>::type Dune::ReduceTuple< F, Tuple, Seed, N >::Value

Function Documentation

template<class... Args>
static ResultType Dune::NullPointerInitialiser< std::tuple< Args...> >::apply ( )
inlinestatic
template<class T >
static Type Dune::AddRefTypeEvaluator< T >::apply ( T &  t)
inlinestatic
template<class T >
static Type Dune::AddPtrTypeEvaluator< T >::apply ( T &  t)
inlinestatic
template<class T >
static Type Dune::AddPtrTypeEvaluator< T & >::apply ( T &  t)
inlinestatic
template<class Tuple >
template<class Functor >
void Dune::ForEachValue< Tuple >::apply ( Functor &  f) const
inline

Applies a function object to each storage element of the std::tuple.

Parameters
fFunction object.
template<class Tuple1 , class Tuple2 >
template<class Functor >
void Dune::ForEachValuePair< Tuple1, Tuple2 >::apply ( Functor &  f)
inline

Applies the function object f to the pair of std::tuple's.

Parameters
fThe function object to apply on the pair of std::tuple's.
template<class Tuple >
template<typename... Ts>
static void Dune::PointerPairDeletor< Tuple >::apply ( std::tuple< Ts...> &  t)
inlinestatic
template<class Tuple >
Dune::ForEachValue< Tuple >::ForEachValue ( Tuple &  t)
inline

Constructor.

Parameters
tThe std::tuple which we want to process.
template<class Tuple1 , class Tuple2 >
Dune::ForEachValuePair< Tuple1, Tuple2 >::ForEachValuePair ( Tuple1 &  t1,
Tuple2 &  t2 
)
inline

Constructor

Parameters
t1First std::tuple.
t2Second std::tuple.
template<class Tuple , class Functor >
auto Dune::genericTransformTuple ( Tuple &&  t,
Functor &&  f 
) ->

This function does for the value of a std::tuple what ForEachType does for the type of a std::tuple: it transforms the value using a user-provided policy functor.

Parameters
tThe std::tuple value to transform.
fThe functor to use to transform the values.

The functor should have the following form:

* struct Functor
* {
* template<class>
* struct TypeEvaluator
* {
* typedef user-defined Type;
* };
*
* template<class T>
* typename TypeEvaluator<T>::Type operator()(T& val);
*
* template<class T>
* typename TypeEvaluator<T>::Type operator()(T& val) const;
*
* template<class T>
* typename TypeEvaluator<T>::Type operator()(const T& val);
*
* template<class T>
* typename TypeEvaluator<T>::Type operator()(const T& val) const;
* };
*

The member class template TypeEvaluator should be a class template suitable as the TypeEvaluator template parameter for ForEachType. The function call operator operator() is used to transform the value; only the signatures of operator() which are actually used must be present.

template<int N>
template<typename Tuple >
static TupleAccessTraits<typename AtType<N, Tuple>::Type>::NonConstType Dune::At< N >::get ( Tuple &  t)
inlinestatic
template<int N>
template<typename Tuple >
static TupleAccessTraits<typename AtType<N, Tuple>::Type>::ConstType Dune::At< N >::get ( const Tuple &  t)
inlinestatic
template<template< class > class TE, class... Args>
TransformTupleFunctor<TE, Args...> Dune::makeTransformTupleFunctor ( Args &&...  args)
template<template< class > class TE, class... Args>
template<class T >
auto Dune::TransformTupleFunctor< TE, Args >::operator() ( T &&  t) -> decltype(this->apply(t,Std::index_sequence_for<Args...>
inline
template<template< class > class TypeEvaluator, class Tuple , class... Args>
auto Dune::transformTuple ( Tuple &&  orig,
Args &&...  args 
) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor<TypeEvaluator>(args...)))

This function provides functionality similar to genericTransformTuple(), although less general and closer in spirit to ForEachType.

Template Parameters
TypeEvaluatorUsed as the TE template argument to TransformTupleFunctor internally.
TupleType of the std::tuple to transform.
ArgsTypes of extra argument to call the transformation function with.
Parameters
origTuple value to be transformed.
argsExtra arguments values to provide to the transformation function.

The TypeEvaluator class template should be suitable as the TE template argument for TransformTupleFunctor. It has the following form (an extension of the TypeEvaluator template argument of ForEachType):

* template <class T>
* struct TypeEvaluator
* {
* typedef UserDefined Type;
*
* template<class... Args>
* static Type apply(T& t, Args&... args);
* };
*
See Also
genericTransforTuple(), ForEachType, AddRefTypeEvaluator, and AddPtrTypeEvaluator.
template<template< class > class TE, class... Args>
Dune::TransformTupleFunctor< TE, Args >::TransformTupleFunctor ( Args &&...  args)
inline

Variable Documentation

template<template< class > class TE, class... Args>
Dune::TransformTupleFunctor< TE, Args >::const
Initial value:
{
return apply(t,Std::index_sequence_for<Args...>{})