3#ifndef DUNE_TYPETRAITS_HH
4#define DUNE_TYPETRAITS_HH
9#include <dune/common/std/utility.hh>
44 struct PointerTraits {
45 enum { result =
false };
46 typedef Empty PointeeType;
50 struct PointerTraits<U*> {
51 enum { result =
true };
52 typedef U PointeeType;
55 template <
class U>
struct ReferenceTraits
57 enum { result =
false };
58 typedef U ReferredType;
61 template <
class U>
struct ReferenceTraits<U&>
63 enum { result =
true };
64 typedef U ReferredType;
68 enum { isPointer = PointerTraits<T>::result };
71 enum { isReference = ReferenceTraits<T>::result };
72 typedef typename ReferenceTraits<T>::ReferredType ReferredType
DUNE_DEPRECATED_MSG(
"Use remove_reference instead!");
110 struct ConstantVolatileTraits<volatile T>
121 struct ConstantVolatileTraits<const volatile T>
151 template<
typename T,
bool isVolatile>
152 struct RemoveConstHelper
158 struct RemoveConstHelper<T,true>
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>
198 class Conversion<From, void>
209 class Conversion<void, To>
220 class Conversion< int, double >
231 class Conversion<T,T>{
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;
303 struct __is_pointer_helper
304 :
public false_type { };
307 struct __is_pointer_helper<T*>
308 :
public true_type { };
313 :
public integral_constant<bool, (__is_pointer_helper<T>::value)>
318 struct __is_lvalue_reference_helper
319 :
public false_type { };
322 struct __is_lvalue_reference_helper<T&>
323 :
public true_type { };
328 :
public integral_constant<bool, (__is_lvalue_reference_helper<T>::value)>
331 template<
typename _Tp>
332 struct __remove_pointer_helper
333 {
typedef _Tp type; };
335 template<
typename _Tp>
336 struct __remove_pointer_helper<_Tp*>
337 {
typedef _Tp type; };
344 template<
typename _Tp>
346 :
public __remove_pointer_helper<typename remove_const<_Tp>::type >
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>
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");
Checks wether a type is convertible to another.
Definition: typetraits.hh:177
@ sameType
True if To and From are the same type.
Definition: typetraits.hh:191
@ exists
True if the conversion exists.
Definition: typetraits.hh:187
@ isTwoWay
Whether the conversion exists in both ways.
Definition: typetraits.hh:189
Checks wether a type is derived from another.
Definition: typetraits.hh:247
@ value
True if Base is a base class of Derived.
Definition: typetraits.hh:258
General type traits class to check whether type is reference or pointer type.
Definition: typetraits.hh:41
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Dune namespace.
Definition: alignment.hh:10
template which always yields a false value
Definition: typetraits.hh:390
static const bool value
always a false value
Definition: typetraits.hh:392
template which always yields a true value
Definition: typetraits.hh:403
static const bool value
always a true value
Definition: typetraits.hh:405
Determines wether a type is const or volatile and provides the unqualified types.
Definition: typetraits.hh:81
const volatile T ConstVolatileType
The const volatile type.
Definition: typetraits.hh:94
T UnqualifiedType
The unqualified type.
Definition: typetraits.hh:90
@ isConst
True if T has a const qualifier.
Definition: typetraits.hh:86
@ isVolatile
True if T has a volatile specifier.
Definition: typetraits.hh:84
const T ConstType
The const type.
Definition: typetraits.hh:92
Just an empty class.
Definition: typetraits.hh:27
Enable typedef if two types are interoperable.
Definition: typetraits.hh:292
Tests wether a type is constant.
Definition: typetraits.hh:144
@ value
True if The type is constant.
Definition: typetraits.hh:147
Checks wether two types are interoperable.
Definition: typetraits.hh:272
@ value
True if either a conversion from T1 to T2 or vice versa exists.
Definition: typetraits.hh:278
Tests wether a type is volatile.
Definition: typetraits.hh:134
@ value
True if The type is volatile.
Definition: typetraits.hh:137
Definition: typetraits.hh:438
Determine whether a type is a lvalue reference type.
Definition: typetraits.hh:329
is_pointer
Definition: typetraits.hh:314
Return the type a pointer type points to.
Definition: typetraits.hh:347