1#ifndef DUNE_FEM_COMMON_TYPEINDEXEDTUPLE_HH
2#define DUNE_FEM_COMMON_TYPEINDEXEDTUPLE_HH
7#include <dune/fem/common/tupleutility.hh>
18 template<
class Tuple,
class Types >
19 class TypeIndexedTuple
28 template<
class T,
bool contained >
31 typedef typename std::tuple_element< Position< T >::value, Tuple >::type Type;
32 static Type& at( Tuple& tuple )
34 return std::get< Position< T >::value >( tuple );
36 static const Type& at(
const Tuple& tuple )
38 return std::get< Position< T >::value >( tuple );
44 struct ValueBase< T, false >
47 static Type& at( Tuple& tuple )
51 static const Type& at(
const Tuple& tuple )
61 static const bool value = ContainsType< Types, T >::value;
65 struct Value :
public ValueBase< T, Contains< T >::value >
69 explicit TypeIndexedTuple (
const Tuple &tuple = Tuple() )
75 typename Value< T >::Type &at ()
77 return Value< T >::at( tuple_ );
82 const typename Value< T >::Type &at ()
const
84 return Value< T >::at( tuple_ );
89 typename Value< T >::Type &operator[] (
const T & )
96 const typename Value< T >::Type &operator[] (
const T & )
const
103 bool active(
const T& )
const {
return Contains< T >::value; }
106 operator Tuple & () {
return tuple_; }
109 operator const Tuple & ()
const {
return tuple_; }
120 template<
int i,
class Tuple,
class Types >
121 typename std::tuple_element< i, Tuple >::type &
122 get ( Dune::TypeIndexedTuple< Tuple, Types > &tuple )
124 return std::get< i >(
static_cast< Tuple &
>( tuple ) );
127 template<
int i,
class Tuple,
class Types >
128 const typename std::tuple_element< i, Tuple >::type &
129 get (
const Dune::TypeIndexedTuple< Tuple, Types > &tuple )
131 return std::get< i >(
static_cast< const Tuple &
>( tuple ) );
141 template<
size_t i,
class Tuple,
class Types >
142 class tuple_element< i,
Dune::TypeIndexedTuple< Tuple, Types > >
145 typedef typename std::tuple_element< i, Tuple >::type type;
Contains utility classes which can be used with std::tuple.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
Find the first occurrence of a type in a std::tuple.
Definition: tupleutility.hh:467