3 #ifndef DUNE_TYPETRAITS_HH 4 #define DUNE_TYPETRAITS_HH 44 struct PointerTraits {
45 enum { result =
false };
50 struct PointerTraits<U*> {
51 enum { result =
true };
55 template <
class U>
struct ReferenceTraits
57 enum { result =
false };
61 template <
class U>
struct ReferenceTraits<U&>
63 enum { result =
true };
68 enum { isPointer = PointerTraits<T>::result };
71 enum { isReference = ReferenceTraits<T>::result };
101 isVolatile=
false, isConst=
true 113 isVolatile=
true, isConst=
false 124 isVolatile=
true, isConst=
true 151 template<
typename T,
bool isVolatile>
163 using std::remove_const;
164 using std::remove_reference;
175 template<
class From,
class To>
179 struct Big {
char dummy[2];};
180 static Small test(To);
181 static Big test(...);
182 static typename remove_reference< From >::type &makeFrom ();
187 exists =
sizeof(test(makeFrom())) ==
sizeof(Small),
197 template <
class From>
233 enum { exists=
true, isTwoWay=
true, sameType=
true};
245 template <
class Base,
class Derived>
251 struct Big {
char dummy[2];};
252 static Small test(RawBase*);
253 static Big test(...);
254 static RawDerived* &makePtr ();
258 value =
sizeof(test(makePtr())) ==
sizeof(Small)
270 template<
class T1,
class T2>
282 using std::enable_if;
289 template<
class T1,
class T2,
class Type>
291 :
public enable_if<IsInteroperable<T1,T2>::value, Type>
296 using std::conditional;
297 using std::integral_constant;
298 using std::true_type;
299 using std::false_type;
304 :
public false_type { };
308 :
public true_type { };
313 :
public integral_constant<bool, (__is_pointer_helper<T>::value)>
319 :
public false_type { };
323 :
public true_type { };
328 :
public integral_constant<bool, (__is_lvalue_reference_helper<T>::value)>
331 template<
typename _Tp>
335 template<
typename _Tp>
344 template<
typename _Tp>
392 static const bool value =
false;
405 static const bool value =
true;
409 #if defined(DOXYGEN) or HAVE_IS_INDEXABLE_SUPPORT 415 template<
typename T,
typename I,
typename =
int>
417 :
public std::false_type
420 template<
typename T,
typename I>
421 struct _is_indexable<T,I,typename std::enable_if<(sizeof(Std::declval<T>()[Std::declval<I>()]) > 0),int>::type>
422 :
public std::true_type
435 template<
typename T,
typename I = std::
size_t>
437 :
public detail::_is_indexable<T,I>
441 #else // defined(DOXYGEN) or HAVE_IS_INDEXABLE_SUPPORT 470 template<
typename T,
typename =
int>
472 :
public std::false_type
477 struct _is_indexable<T,decltype(Std::
declval<T>()[0],0)>
478 :
public std::true_type
484 struct _check_for_index_operator
489 :
public _is_indexable<T>
506 template<
typename T,
typename I = std::
size_t>
508 :
public std::conditional<
509 std::is_array<T>::value,
510 detail::_lazy<std::true_type>,
511 typename std::conditional<
512 std::is_class<T>::value,
513 detail::_check_for_index_operator,
514 detail::_lazy<std::false_type>
516 >::type::template evaluate<T>::type
518 static_assert(std::is_same<I,std::size_t>::value,
"Your compiler is broken and does not support checking for arbitrary index types");
522 #endif // defined(DOXYGEN) or HAVE_IS_INDEXABLE_SUPPORT General type traits class to check whether type is reference or pointer type.
Definition: typetraits.hh:40
ReferenceTraits< T >::ReferredType ReferredType
Definition: typetraits.hh:72
is_pointer
Definition: typetraits.hh:312
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
const volatile T ConstVolatileType
The const volatile type.
Definition: typetraits.hh:94
T UnqualifiedType
Definition: typetraits.hh:115
Determines wether a type is const or volatile and provides the unqualified types. ...
Definition: typetraits.hh:80
Checks wether two types are interoperable.
Definition: typetraits.hh:271
Conversion()
Definition: typetraits.hh:193
const UnqualifiedType ConstType
Definition: typetraits.hh:104
const volatile UnqualifiedType ConstVolatileType
Definition: typetraits.hh:117
Determine whether a type is a lvalue reference type.
Definition: typetraits.hh:327
_Tp type
Definition: typetraits.hh:333
Enable typedef if two types are interoperable.
Definition: typetraits.hh:290
Definition: typetraits.hh:332
std::add_rvalue_reference< T >::type declval() DUNE_NOEXCEPT
IsBaseOf()
Definition: typetraits.hh:260
const UnqualifiedType ConstType
Definition: typetraits.hh:127
const volatile UnqualifiedType ConstVolatileType
Definition: typetraits.hh:105
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Tests wether a type is constant.
Definition: typetraits.hh:143
template which always yields a true value
Definition: typetraits.hh:403
Definition: typetraits.hh:318
const UnqualifiedType ConstType
Definition: typetraits.hh:116
Definition: typetraits.hh:152
Tests wether a type is volatile.
Definition: typetraits.hh:133
Checks wether a type is convertible to another.
Definition: typetraits.hh:176
Definition: typetraits.hh:436
volatile ConstantVolatileTraits< T >::UnqualifiedType Type
Definition: typetraits.hh:160
Checks wether a type is derived from another.
Definition: typetraits.hh:246
T UnqualifiedType
The unqualified type.
Definition: typetraits.hh:90
ConstantVolatileTraits< T >::UnqualifiedType Type
Definition: typetraits.hh:154
template which always yields a false value
Definition: typetraits.hh:390
_Tp type
Definition: typetraits.hh:337
Dune namespace.
Definition: alignment.hh:9
Just an empty class.
Definition: typetraits.hh:27
const T ConstType
The const type.
Definition: typetraits.hh:92
Return the type a pointer type points to.
Definition: typetraits.hh:345
T UnqualifiedType
Definition: typetraits.hh:103
Definition: typetraits.hh:303
T UnqualifiedType
Definition: typetraits.hh:126
const volatile UnqualifiedType ConstVolatileType
Definition: typetraits.hh:128