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 };
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>
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>
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
True if T has a const qualifier.
Definition: typetraits.hh:86
volatile ConstantVolatileTraits< T >::UnqualifiedType Type
Definition: typetraits.hh:160
True if The type is volatile.
Definition: typetraits.hh:137
const UnqualifiedType ConstType
Definition: typetraits.hh:104
General type traits class to check whether type is reference or pointer type.
Definition: typetraits.hh:40
Tests wether a type is constant.
Definition: typetraits.hh:143
template which always yields a true value
Definition: typetraits.hh:403
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Definition: typetraits.hh:318
const T ConstType
The const type.
Definition: typetraits.hh:92
Definition: typetraits.hh:71
T UnqualifiedType
Definition: typetraits.hh:103
static const bool value
always a false value
Definition: typetraits.hh:392
T UnqualifiedType
Definition: typetraits.hh:126
Definition: typetraits.hh:152
True if Base is a base class of Derived.
Definition: typetraits.hh:258
Tests wether a type is volatile.
Definition: typetraits.hh:133
Checks wether a type is derived from another.
Definition: typetraits.hh:246
T UnqualifiedType
The unqualified type.
Definition: typetraits.hh:90
const UnqualifiedType ConstType
Definition: typetraits.hh:127
True if T has a volatile specifier.
Definition: typetraits.hh:84
_Tp type
Definition: typetraits.hh:337
template which always yields a false value
Definition: typetraits.hh:390
_Tp type
Definition: typetraits.hh:333
True if To and From are the same type.
Definition: typetraits.hh:191
Just an empty class.
Definition: typetraits.hh:27
Conversion()
Definition: typetraits.hh:193
Return the type a pointer type points to.
Definition: typetraits.hh:345
Definition: typetraits.hh:303
const volatile UnqualifiedType ConstVolatileType
Definition: typetraits.hh:117
ConstantVolatileTraits< T >::UnqualifiedType Type
Definition: typetraits.hh:154
True if the conversion exists.
Definition: typetraits.hh:187
ReferenceTraits< T >::ReferredType ReferredType
Definition: typetraits.hh:72
std::add_rvalue_reference< T >::type declval() DUNE_NOEXCEPT
is_pointer
Definition: typetraits.hh:312
IsBaseOf()
Definition: typetraits.hh:260
Checks wether a type is convertible to another.
Definition: typetraits.hh:176
PointerTraits< T >::PointeeType PointeeType
Definition: typetraits.hh:69
Definition: typetraits.hh:436
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
const volatile UnqualifiedType ConstVolatileType
Definition: typetraits.hh:105
True if either a conversion from T1 to T2 or vice versa exists.
Definition: typetraits.hh:278
Definition: typetraits.hh:68
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
const volatile UnqualifiedType ConstVolatileType
Definition: typetraits.hh:128
True if The type is constant.
Definition: typetraits.hh:147
static const bool value
always a true value
Definition: typetraits.hh:405
Determine whether a type is a lvalue reference type.
Definition: typetraits.hh:327
Whether the conversion exists in both ways.
Definition: typetraits.hh:189
T UnqualifiedType
Definition: typetraits.hh:115
const volatile T ConstVolatileType
The const volatile type.
Definition: typetraits.hh:94
Enable typedef if two types are interoperable.
Definition: typetraits.hh:290
const UnqualifiedType ConstType
Definition: typetraits.hh:116
Definition: typetraits.hh:332