1#ifndef DUNE_FEM_PASS_COMMON_TUPLETYPETRAITS_HH
2#define DUNE_FEM_PASS_COMMON_TUPLETYPETRAITS_HH
7#include <dune/common/hybridutilities.hh>
11#include <dune/fem/common/tupleutility.hh>
19 template<
class Tuple,
20 template<
class >
class Predicate,
21 int N = std::tuple_size< Tuple >::value
23 struct CheckAllElements
25 static const bool value = ( Predicate<
typename std::tuple_element< N-1, Tuple >::type >::value
26 && CheckAllElements< Tuple, Predicate, (N-1) >::value );
29 template<
class Tuple,
30 template<
class >
class Predicate
32 struct CheckAllElements< Tuple, Predicate, 0 >
34 static const bool value =
true;
52 class Seed = std::tuple<>,
55 struct SingleTypeTuple
57 typedef typename SingleTypeTuple< T, size, typename Dune::PushBackTuple< Seed, T >::type, (index+1) >::Type Type;
64 struct SingleTypeTuple< T,
size, Seed,
size >
79 :
public SingleTypeTuple< Dune::Empty, size >
90 template<
class Tuple >
96 static const bool value = std::is_pointer<T>::value;
102 static const bool value = std::is_lvalue_reference<T>::value;
106 struct PointeeTypeEvaluator
108 typedef typename std::remove_pointer<T>::type Type;
112 struct ReferredTypeEvaluator
114 typedef typename std::remove_reference<T>::type Type;
118 static const bool isPointerTuple = CheckAllElements< Tuple, IsPointer >::value;
120 typedef typename std::conditional< isPointerTuple,
122 EmptyTuple< std::tuple_size< Tuple >::value >
123 >::type PointeeTupleType;
125 static const bool isReferenceTuple = CheckAllElements< Tuple, IsReference >::value;
140 template<
class Tuple >
144 struct PointerEvaluator
146 typedef typename std::remove_pointer<T>::type * Type;
163 template<
class Tuple >
167 struct ReferenceEvaluator
169 typedef typename std::remove_reference<T>::type & Type;
186 template<
class Tuple >
190 struct ConstEvaluator
192 typedef typename std::add_const<typename std::remove_cv<T>::type>::type Type;
207 template<
class Tuple >
211 struct RemoveConstEvaluator
213 typedef typename std::remove_cv< T >::type Type;
228 template<
class Tuple >
229 struct tuple_remove_const
231 typedef typename RemoveConstTuple< Tuple >::Type type;
244 template<
class Tuple >
247 static_assert( TupleTypeTraits< Tuple >::isPointerTuple,
"Can not check non-pointer tuple." );
249 static bool apply (
const Tuple &tuple )
252 Hybrid::forEach( tuple, [ & ](
auto&& ti ){ check &=
static_cast< bool >( ti ); } );
265 template<
class Tuple,
266 class Seed = std::tuple<>,
268 int size = std::tuple_size< Tuple >::value
274 typedef typename std::remove_pointer< typename std::tuple_element< index, Tuple >::type >::type & AppendType;
281 typename Dune::TupleTypeTraits< Tuple >::PointeeTupleType
284 static Type apply ( Tuple &tuple )
287 return append( tuple, seed );
291 static Type append ( Tuple &tuple, Seed &seed )
293 typename std::tuple_element< index, Tuple >::type pointer = std::get< index >( tuple );
294 AppendType append = *pointer;
295 AccumulatedType next = Dune::tuple_push_back< AppendType >( seed, append );
296 return NextType::append( tuple, next );
300 template<
class Tuple,
310 typename Dune::TupleTypeTraits< Tuple >::PointeeTupleType
313 static_assert( (std::is_same< Seed, Type >::value),
"Failed to dereference pointer tuple." );
315 static Type apply ( Tuple & )
321 static Seed append ( Tuple &tuple, Seed &seed ) {
return seed; }
Add const qualifier to all tuple elements.
Definition: tupletypetraits.hh:188
Dereference pointer tuple.
Definition: tupletypetraits.hh:271
Convert a tuple to a tuple of pointer types.
Definition: tupletypetraits.hh:142
Convert a tuple to a tuple of references.
Definition: tupletypetraits.hh:165
Remove const qualifiers from tuple.
Definition: tupletypetraits.hh:209
Contains utility classes which can be used with std::tuple.
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:256
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition: tupleutility.hh:116
Helper template to append a type to a std::tuple.
Definition: tupleutility.hh:476
Check whether a pointer tuple can be dereferenced.
Definition: tupletypetraits.hh:246
Traits for type conversions and type information.