3#ifndef DUNE_TYPETRAITS_HH
4#define DUNE_TYPETRAITS_HH
6#if defined HAVE_TYPE_TRAITS
8#elif defined HAVE_TR1_TYPE_TRAITS
9#include <tr1/type_traits>
47 struct PointerTraits {
48 enum { result =
false };
49 typedef Empty PointeeType;
53 struct PointerTraits<U*> {
54 enum { result =
true };
55 typedef U PointeeType;
58 template <
class U>
struct ReferenceTraits
60 enum { result =
false };
61 typedef U ReferredType;
64 template <
class U>
struct ReferenceTraits<U&>
66 enum { result =
true };
67 typedef U ReferredType;
71 enum { isPointer = PointerTraits<T>::result };
74 enum { isReference = ReferenceTraits<T>::result };
75 typedef typename ReferenceTraits<T>::ReferredType ReferredType
DUNE_DEPRECATED_MSG(
"Use remove_reference instead!");
113 struct ConstantVolatileTraits<volatile T>
124 struct ConstantVolatileTraits<const volatile T>
154 template<
typename T,
bool isVolatile>
155 struct RemoveConstHelper
161 struct RemoveConstHelper<T,true>
166#if defined HAVE_TYPE_TRAITS
167 using std::remove_const;
168#elif defined HAVE_TR1_TYPE_TRAITS
169 using std::tr1::remove_const;
177 typedef typename RemoveConstHelper<T, IsVolatile<T>::value>::Type type;
181#if defined HAVE_TYPE_TRAITS
182 using std::remove_reference;
183#elif defined HAVE_TR1_TYPE_TRAITS
184 using std::tr1::remove_reference;
211 template<
class From,
class To>
215 struct Big {
char dummy[2];};
216 static Small test(To);
217 static Big test(...);
223 exists =
sizeof(test(makeFrom())) ==
sizeof(Small),
233 template <
class From>
234 class Conversion<From, void>
245 class Conversion<void, To>
256 class Conversion< int, double >
267 class Conversion<T,T>{
281 template <
class Base,
class Derived>
287 struct Big {
char dummy[2];};
288 static Small test(RawBase*);
289 static Big test(...);
290 static RawDerived* &makePtr ();
294 value =
sizeof(test(makePtr())) ==
sizeof(Small)
306 template<
class T1,
class T2>
318#ifdef HAVE_TYPE_TRAITS
319 using std::enable_if;
327 template<
bool b,
typename T=
void>
344 template<
class T1,
class T2,
class Type>
346 :
public enable_if<IsInteroperable<T1,T2>::value, Type>
349#if defined HAVE_TYPE_TRAITS
351#elif defined HAVE_TR1_TYPE_TRAITS
352 using std::tr1::is_same;
358 template<
typename T1,
typename T2>
386 template<
bool first,
class T1,
class T2>
398 template<
class T1,
class T2>
404#if DOXYGEN || !HAVE_STD_CONDITIONAL
417 template<
bool first,
class T1,
class T2>
429 template<
class T1,
class T2>
438 using std::conditional;
446#if HAVE_INTEGRAL_CONSTANT
447 using std::integral_constant;
456 template <
class T, T v>
475 struct __is_pointer_helper
479 struct __is_pointer_helper<T*>
490 struct __is_lvalue_reference_helper
494 struct __is_lvalue_reference_helper<T&>
503 template<
typename _Tp>
504 struct __remove_pointer_helper
505 {
typedef _Tp type; };
507 template<
typename _Tp>
508 struct __remove_pointer_helper<_Tp*>
509 {
typedef _Tp type; };
516 template<
typename _Tp>
518 :
public __remove_pointer_helper<typename remove_const<_Tp>::type >
Checks wether a type is convertible to another.
Definition: typetraits.hh:213
@ sameType
True if To and From are the same type.
Definition: typetraits.hh:227
@ exists
True if the conversion exists.
Definition: typetraits.hh:223
@ isTwoWay
Whether the conversion exists in both ways.
Definition: typetraits.hh:225
Checks wether a type is derived from another.
Definition: typetraits.hh:283
@ value
True if Base is a base class of Derived.
Definition: typetraits.hh:294
General type traits class to check whether type is reference or pointer type.
Definition: typetraits.hh:44
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
integral_constant< bool, true > true_type
type for true
Definition: typetraits.hh:469
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
#define DUNE_DEPRECATED
Mark some entity as deprecated.
Definition: deprecated.hh:84
integral_constant< bool, false > false_type
type for false
Definition: typetraits.hh:471
Dune namespace.
Definition: alignment.hh:14
Determines wether a type is const or volatile and provides the unqualified types.
Definition: typetraits.hh:84
const volatile T ConstVolatileType
The const volatile type.
Definition: typetraits.hh:97
T UnqualifiedType
The unqualified type.
Definition: typetraits.hh:93
@ isConst
True if T has a const qualifier.
Definition: typetraits.hh:89
@ isVolatile
True if T has a volatile specifier.
Definition: typetraits.hh:87
const T ConstType
The const type.
Definition: typetraits.hh:95
Just an empty class.
Definition: typetraits.hh:30
Enable typedef if two types are interoperable.
Definition: typetraits.hh:347
Tests wether a type is constant.
Definition: typetraits.hh:147
@ value
True if The type is constant.
Definition: typetraits.hh:150
Checks wether two types are interoperable.
Definition: typetraits.hh:308
@ value
True if either a conversion from T1 to T2 or vice versa exists.
Definition: typetraits.hh:314
Tests wether a type is volatile.
Definition: typetraits.hh:137
@ value
True if The type is volatile.
Definition: typetraits.hh:140
Select a type based on a condition.
Definition: typetraits.hh:388
T1 Type DUNE_DEPRECATED_MSG("Use Dune::conditional::type instead")
The selected type.
Definition: typetraits.hh:395
Select a type based on a condition.
Definition: typetraits.hh:419
T1 type
The selected type.
Definition: typetraits.hh:426
Enable typedef if condition is met.
Definition: typetraits.hh:329
Generate a type for a given integral constant.
Definition: typetraits.hh:457
static const T value
value this type was generated for
Definition: typetraits.hh:459
T value_type
type of value
Definition: typetraits.hh:461
integral_constant< T, v > type
type of this class itself
Definition: typetraits.hh:463
Determine whether a type is a lvalue reference type.
Definition: typetraits.hh:501
is_pointer
Definition: typetraits.hh:486
Compile time test for testing whether two types are the same.
Definition: typetraits.hh:360
Removes a const qualifier while preserving others.
Definition: typetraits.hh:176
Return the type a pointer type points to.
Definition: typetraits.hh:519
Remove a reference from a type.
Definition: typetraits.hh:191
T type
T with references removed.
Definition: typetraits.hh:193