3#ifndef DUNE_TYPETRAITS_HH
4#define DUNE_TYPETRAITS_HH
39 template <
class... Types>
40 using void_t =
typename Impl::voider<Types...>::type;
63 template<
class T1,
class T2>
71 value = std::is_convertible<T1,T2>::value || std::is_convertible<T2,T1>::value
80 template<
class T1,
class T2,
class Type>
82 :
public std::enable_if<IsInteroperable<T1,T2>::value, Type>
161 template <
typename T>
163 :
public std::integral_constant<bool, std::is_arithmetic<T>::value> {
168 template <
typename T>
170 :
public std::integral_constant<bool, IsNumber<T>::value> {
179 template <
typename T>
181 :
public std::integral_constant<bool, std::is_floating_point<T>::value> {
186 template <
typename T>
188 :
public std::integral_constant<bool, std::is_floating_point<T>::value> {
198 template <
typename T>
202#if defined(DOXYGEN) or HAVE_IS_INDEXABLE_SUPPORT
208 template<
typename T,
typename I,
typename =
int>
210 :
public std::false_type
213 template<
typename T,
typename I>
214 struct IsIndexable<T,I,typename
std::enable_if<(sizeof(std::declval<T>()[std::declval<I>()]) > 0),int>::type>
215 :
public std::true_type
227 template<
typename T,
typename I = std::
size_t>
229 :
public Impl::IsIndexable<T,I>
261 template<
typename T,
typename =
int>
263 :
public std::false_type
268 struct IsIndexable<T,decltype(
std::declval<T>()[0],0)>
269 :
public std::true_type
275 struct _check_for_index_operator
280 :
public IsIndexable<T>
297 template<
typename T,
typename I = std::
size_t>
299 :
public std::conditional<
300 std::is_array<T>::value,
301 Impl::_lazy<std::true_type>,
302 typename std::conditional<
303 std::is_class<T>::value,
304 Impl::_check_for_index_operator,
305 Impl::_lazy<std::false_type>
307 >::type::template evaluate<T>::type
309 static_assert(std::is_same<I,std::size_t>::value,
"Your compiler is broken and does not support checking for arbitrary index types");
321 template<
typename T,
typename I = std::
size_t>
343 template<
typename T,
typename =
void>
345 :
public std::false_type
352 std::declval<T>().begin(),
353 std::declval<T>().end(),
354 std::declval<T>().begin() != std::declval<T>().end(),
355 decltype(std::declval<T>().begin()){std::declval<T>().end()},
356 ++(std::declval<std::add_lvalue_reference_t<decltype(std::declval<T>().begin())>>()),
357 *(std::declval<T>().begin())
359 :
public std::true_type
367 template<
typename T,
typename =
void>
373 template <
class>
struct FieldTraits;
377 template <
class Type>
378 using field_t =
typename FieldTraits<Type>::field_type;
381 template <
class Type>
382 using real_t =
typename FieldTraits<Type>::real_type;
391 struct IsTuple :
public std::false_type
395 struct IsTuple<
std::tuple<T...>> :
public std::true_type
409 public Impl::IsTuple<T>
418 template<
class... T,
class Dummy>
419 std::true_type isTupleOrDerived(
const std::tuple<T...>*, Dummy)
422 template<
class Dummy>
423 std::false_type isTupleOrDerived(
const void*, Dummy)
437 public decltype(Impl::isTupleOrDerived(std::declval<T*>(), true))
450 template<
class T, T t>
451 struct IsIntegralConstant<
std::integral_constant<T, t>> :
public std::true_type
482 template<
typename... T>
484 :
public std::integral_constant<std::size_t,sizeof...(T)>
492 template<
class T, T...>
493 struct IntegerSequenceHelper;
501 template<
class T, T head, T... tail>
502 struct IntegerSequenceHelper<T, head, tail...>
506 static constexpr auto get(std::integral_constant<std::size_t, 0>)
508 return std::integral_constant<T, head>();
512 template<std::size_t index,
513 std::enable_if_t<(index > 0) and (index <
sizeof...(tail)+1),
int> = 0>
514 static constexpr auto get(std::integral_constant<std::size_t, index>)
516 return IntegerSequenceHelper<T, tail...>::get(std::integral_constant<std::size_t, index-1>());
520 template<std::size_t index,
521 std::enable_if_t<(index >=
sizeof...(tail)+1),
int> = 0>
522 static constexpr auto get(std::integral_constant<std::size_t, index>)
524 static_assert(index <
sizeof...(tail)+1,
"index used in IntegerSequenceEntry exceed size");
542 template<
class T, T... t, std::size_t index>
543 constexpr auto integerSequenceEntry(std::integer_sequence<T, t...> , std::integral_constant<std::size_t, index> i)
545 static_assert(index <
sizeof...(t),
"index used in IntegerSequenceEntry exceed size");
546 return Impl::IntegerSequenceHelper<T, t...>::get(i);
556 template<
class IntegerSequence, std::
size_t index>
561 template<
class T, T... t, std::size_t i>
563 :
public decltype(Impl::IntegerSequenceHelper<T, t...>::get(std::integral_constant<std::size_t, i>()))
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
constexpr auto integerSequenceEntry(std::integer_sequence< T, t... >, std::integral_constant< std::size_t, index > i)
Get entry of std::integer_sequence.
Definition: typetraits.hh:543
typename FieldTraits< Type >::real_type real_t
Convenient access to FieldTraits<Type>::real_type.
Definition: typetraits.hh:382
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition: typetraits.hh:723
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition: typetraits.hh:639
typename Impl::voider< Types... >::type void_t
Is void for all valid input types (see N3911). The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
typename FieldTraits< Type >::field_type field_t
Convenient access to FieldTraits<Type>::field_type.
Definition: typetraits.hh:378
Dune namespace.
Definition: alignedallocator.hh:14
template which always yields a false value
Definition: typetraits.hh:126
static const bool value
always a false value
Definition: typetraits.hh:128
template which always yields a true value
Definition: typetraits.hh:139
static const bool value
always a true value
Definition: typetraits.hh:141
Type free of internal references that T can be converted to.
Definition: typetraits.hh:582
Just an empty class.
Definition: typetraits.hh:55
Enable typedef if two types are interoperable.
Definition: typetraits.hh:83
Whether this type has a value of NaN.
Definition: typetraits.hh:181
Get entry of std::integer_sequence.
Definition: typetraits.hh:557
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed...
Definition: typetraits.hh:230
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:465
Checks whether two types are interoperable.
Definition: typetraits.hh:65
@ value
True if either a conversion from T1 to T2 or vice versa exists.
Definition: typetraits.hh:71
typetrait to check that a class has begin() and end() members
Definition: typetraits.hh:346
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:163
Check if T derived from a std::tuple<...>
Definition: typetraits.hh:438
Check if T is a std::tuple<...>
Definition: typetraits.hh:410
Compute size of variadic type list.
Definition: typetraits.hh:485
Whether this type has a value of NaN.
Definition: typetraits.hh:200
Definition: typetraits.hh:323
typetrait to check that a class has begin() and end() members
Definition: typetraits.hh:369