3#ifndef DUNE_TYPETRAITS_HH
4#define DUNE_TYPETRAITS_HH
38 template <
class... Types>
39 using void_t =
typename Impl::voider<Types...>::type;
62 template<
class T1,
class T2>
70 value = std::is_convertible<T1,T2>::value || std::is_convertible<T2,T1>::value
79 template<
class T1,
class T2,
class Type>
81 :
public std::enable_if<IsInteroperable<T1,T2>::value, Type>
160 template <
typename T>
162 :
public std::integral_constant<bool, std::is_arithmetic<T>::value> {
167 template <
typename T>
169 :
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> {
194#if defined(DOXYGEN) or HAVE_IS_INDEXABLE_SUPPORT
200 template<
typename T,
typename I,
typename =
int>
202 :
public std::false_type
205 template<
typename T,
typename I>
206 struct _is_indexable<T,I,typename
std::enable_if<(sizeof(std::declval<T>()[std::declval<I>()]) > 0),int>::type>
207 :
public std::true_type
219 template<
typename T,
typename I = std::
size_t>
221 :
public Impl::_is_indexable<T,I>
254 template<
typename T,
typename =
int>
256 :
public std::false_type
261 struct _is_indexable<T,decltype(
std::declval<T>()[0],0)>
262 :
public std::true_type
268 struct _check_for_index_operator
273 :
public _is_indexable<T>
290 template<
typename T,
typename I = std::
size_t>
292 :
public std::conditional<
293 std::is_array<T>::value,
294 Impl::_lazy<std::true_type>,
295 typename std::conditional<
296 std::is_class<T>::value,
297 Impl::_check_for_index_operator,
298 Impl::_lazy<std::false_type>
300 >::type::template evaluate<T>::type
302 static_assert(std::is_same<I,std::size_t>::value,
"Your compiler is broken and does not support checking for arbitrary index types");
326 template<
typename T,
typename =
void>
328 :
public std::false_type
334 struct is_range<T, decltype(Impl::ignore(
335 std::declval<T>().begin(),
336 std::declval<T>().end(),
337 std::declval<T>().begin() != std::declval<T>().end(),
338 decltype(std::declval<T>().begin()){std::declval<T>().end()},
339 ++(std::declval<std::add_lvalue_reference_t<decltype(std::declval<T>().begin())>>()),
340 *(std::declval<T>().begin())
342 :
public std::true_type
348 template <
class>
struct FieldTraits;
352 template <
class Type>
353 using field_t =
typename FieldTraits<Type>::field_type;
356 template <
class Type>
357 using real_t =
typename FieldTraits<Type>::real_type;
366 struct IsTuple :
public std::false_type
370 struct IsTuple<
std::tuple<T...>> :
public std::true_type
384 public Impl::IsTuple<T>
393 template<
class... T,
class Dummy>
394 std::true_type isTupleOrDerived(
const std::tuple<T...>*, Dummy)
397 template<
class Dummy>
398 std::false_type isTupleOrDerived(
const void*, Dummy)
412 public decltype(Impl::isTupleOrDerived(std::declval<T*>(), true))
425 template<
class T, T t>
426 struct IsIntegralConstant<
std::integral_constant<T, t>> :
public std::true_type
457 template<
typename... T>
459 :
public std::integral_constant<std::size_t,sizeof...(T)>
467 template<
class T, T...>
468 struct IntegerSequenceHelper;
476 template<
class T, T head, T... tail>
477 struct IntegerSequenceHelper<T, head, tail...>
481 static constexpr auto get(std::integral_constant<std::size_t, 0>)
483 return std::integral_constant<T, head>();
487 template<std::size_t index,
488 std::enable_if_t<(index > 0) and (index <
sizeof...(tail)+1),
int> = 0>
489 static constexpr auto get(std::integral_constant<std::size_t, index>)
491 return IntegerSequenceHelper<T, tail...>::get(std::integral_constant<std::size_t, index-1>());
495 template<std::size_t index,
496 std::enable_if_t<(index >=
sizeof...(tail)+1),
int> = 0>
497 static constexpr auto get(std::integral_constant<std::size_t, index>)
499 static_assert(index <
sizeof...(tail)+1,
"index used in IntegerSequenceEntry exceed size");
517 template<
class T, T... t, std::size_t index>
518 constexpr auto integerSequenceEntry(std::integer_sequence<T, t...> , std::integral_constant<std::size_t, index> i)
520 static_assert(index <
sizeof...(t),
"index used in IntegerSequenceEntry exceed size");
521 return Impl::IntegerSequenceHelper<T, t...>::get(i);
531 template<
class IntegerSequence, std::
size_t index>
536 template<
class T, T... t, std::size_t i>
538 :
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:518
typename FieldTraits< Type >::real_type real_t
Convenient access to FieldTraits<Type>::real_type.
Definition: typetraits.hh:357
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:39
typename FieldTraits< Type >::field_type field_t
Convenient access to FieldTraits<Type>::field_type.
Definition: typetraits.hh:353
Dune namespace.
Definition: alignedallocator.hh:10
template which always yields a false value
Definition: typetraits.hh:125
static const bool value
always a false value
Definition: typetraits.hh:127
template which always yields a true value
Definition: typetraits.hh:138
static const bool value
always a true value
Definition: typetraits.hh:140
Just an empty class.
Definition: typetraits.hh:54
Enable typedef if two types are interoperable.
Definition: typetraits.hh:82
Get entry of std::integer_sequence.
Definition: typetraits.hh:532
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:440
Checks whether two types are interoperable.
Definition: typetraits.hh:64
@ value
True if either a conversion from T1 to T2 or vice versa exists.
Definition: typetraits.hh:70
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:162
Check if T derived from a std::tuple<...>
Definition: typetraits.hh:413
Check if T is a std::tuple<...>
Definition: typetraits.hh:385
Compute size of variadic type list.
Definition: typetraits.hh:460
Whether this type has a value of NaN.
Definition: typetraits.hh:181
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed...
Definition: typetraits.hh:222
typetrait to check that a class has begin() and end() members
Definition: typetraits.hh:329