Dune Core Modules (2.10.0)

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::NullPointerInitialiser< T >
 A helper template that initializes a std::tuple consisting of pointers to nullptr. More...
 
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...
 
class  Dune::TransformTupleFunctor< TE, Args >
 
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::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::PushFrontTuple< Tuple, T >
 Helper template to prepend a type to a std::tuple. More...
 
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 F< Accumulated, Value >::type Dune::ReduceTuple< F, Tuple, Seed, N >::type
 Result of the reduce operation.
 
typedef Seed Dune::ReduceTuple< F, Tuple, Seed, 0 >::type
 Result of the reduce operation.
 
typedef ReduceTuple< PushBackTuple, Tail, Head >::type Dune::JoinTuples< Head, Tail >::type
 Result of the join operation.
 
typedef ReduceTuple< JoinTuples, Tuple >::type Dune::FlattenTuple< Tuple >::type
 Result of the flatten operation.
 

Functions

template<class Tuple , class Functor >
auto Dune::genericTransformTuple (Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
 
template<template< class > class TypeEvaluator, class Tuple , class... Args>
auto Dune::transformTuple (Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
 

Detailed Description

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

Function Documentation

◆ genericTransformTuple()

template<class Tuple , class Functor >
auto Dune::genericTransformTuple ( Tuple &&  t,
Functor &&  f 
) -> decltype(genericTransformTupleBackend(t, 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.

Referenced by Dune::transformTuple().

◆ transformTuple()

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.

References Dune::genericTransformTuple().

Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)