5#ifndef DUNE_TYPETRAITS_HH
6#define DUNE_TYPETRAITS_HH
39 template <
class... Types>
40 using void_t =
typename Impl::voider<Types...>::type;
63 template<
class T1,
class T2>
70 constexpr static bool value = std::is_convertible<T1,T2>::value || std::is_convertible<T2,T1>::value;
78 template<
class T1,
class T2,
class Type>
80 :
public std::enable_if<IsInteroperable<T1,T2>::value, Type>
161 template<
typename D,
typename R =
void>
168 template<
typename R,
typename F,
typename... Args>
170 :
public std::bool_constant<
171 std::is_invocable_r_v<R, F, Args...>
172 && !std::is_member_pointer_v<std::decay_t<F>>
192 template <
typename T>
194 :
public std::integral_constant<bool, std::is_arithmetic<T>::value> {
199 template <
typename T>
201 :
public std::integral_constant<bool, IsNumber<T>::value> {
210 template <
typename T>
212 :
public std::integral_constant<bool, std::is_floating_point<T>::value> {
217 template <
typename T>
219 :
public std::integral_constant<bool, std::is_floating_point<T>::value> {
228 template<
typename T,
typename I,
typename =
int>
230 :
public std::false_type
233 template<
typename T,
typename I>
234 struct IsIndexable<T,I,typename
std::enable_if<(sizeof(std::declval<T>()[std::declval<I>()]) > 0),int>::type>
235 :
public std::true_type
247 template<
typename T,
typename I = std::
size_t>
249 :
public Impl::IsIndexable<T,I>
270 template<
typename T,
typename =
void>
272 :
public std::false_type
279 std::declval<T>().begin(),
280 std::declval<T>().end(),
281 std::declval<T>().begin() != std::declval<T>().end(),
282 decltype(std::declval<T>().begin()){std::declval<T>().end()},
283 ++(std::declval<std::add_lvalue_reference_t<decltype(std::declval<T>().begin())>>()),
284 *(std::declval<T>().begin())
286 :
public std::true_type
292 template <
class>
struct FieldTraits;
296 template <
class Type>
297 using field_t =
typename FieldTraits<Type>::field_type;
300 template <
class Type>
301 using real_t =
typename FieldTraits<Type>::real_type;
310 struct IsTuple :
public std::false_type
314 struct IsTuple<
std::tuple<T...>> :
public std::true_type
328 public Impl::IsTuple<T>
337 template<
class... T,
class Dummy>
338 std::true_type isTupleOrDerived(
const std::tuple<T...>*, Dummy)
341 template<
class Dummy>
342 std::false_type isTupleOrDerived(
const void*, Dummy)
356 public decltype(Impl::isTupleOrDerived(std::declval<T*>(), true))
369 template<
class T, T t>
370 struct IsIntegralConstant<
std::integral_constant<T, t>> :
public std::true_type
393 template <
class T, T value>
394 static std::true_type check(std::integral_constant<T,value>);
395 static std::false_type check(...);
410 :
public decltype(Impl::IsCompileTimeConstant::check(std::declval<T>()))
430 template<
typename... T>
432 [[deprecated(
"This class is deprecated and will be removed after Dune 2.10. Use sizeof...(T) instead.")]]
434 :
public std::integral_constant<std::size_t,
sizeof...(T)>
442 template<
class T, T...>
443 struct IntegerSequenceHelper;
451 template<
class T, T
head, T...
tail>
452 struct IntegerSequenceHelper<T,
head,
tail...>
456 static constexpr auto get(std::integral_constant<std::size_t, 0>)
458 return std::integral_constant<T, head>();
462 template<std::size_t index,
463 std::enable_if_t<(index > 0) and (index <
sizeof...(
tail)+1),
int> = 0>
464 static constexpr auto get(std::integral_constant<std::size_t, index>)
466 return IntegerSequenceHelper<T, tail...>::get(std::integral_constant<std::size_t, index-1>());
470 template<std::size_t index,
471 std::enable_if_t<(index >=
sizeof...(tail)+1),
int> = 0>
472 static constexpr auto get(std::integral_constant<std::size_t, index>)
474 static_assert(index <
sizeof...(tail)+1,
"index used in IntegerSequenceEntry exceed size");
491 template<
class T, T... t, std::size_t index>
492 [[deprecated(
"Use get(std::integer_sequence<...>, index) instead.")]]
493 constexpr auto integerSequenceEntry(std::integer_sequence<T, t...> , std::integral_constant<std::size_t, index> i)
495 static_assert(index <
sizeof...(t),
"index used in IntegerSequenceEntry exceed size");
496 return Impl::IntegerSequenceHelper<T, t...>::get(i);
506 template<
class IntegerSequence, std::
size_t index>
511 template<
class T, T... t, std::size_t i>
512 struct [[deprecated("Use
get(
std::integer_sequence<...>, index) instead.")]]
IntegerSequenceEntry<std::integer_sequence<T, t...>, i>
513 :
public decltype(Impl::IntegerSequenceHelper<T, t...>::get(std::integral_constant<std::size_t, i>()))
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:493
typename FieldTraits< Type >::real_type real_t
Convenient access to FieldTraits<Type>::real_type.
Definition: typetraits.hh:301
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition: typetraits.hh:589
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
typename FieldTraits< Type >::field_type field_t
Convenient access to FieldTraits<Type>::field_type.
Definition: typetraits.hh:297
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integer_sequence< T, II... > tail(std::integer_sequence< T, I0, II... >)
For a sequence [head,tail...) return the tail sequence.
Definition: integersequence.hh:58
constexpr std::integral_constant< T, I0 > head(std::integer_sequence< T, I0, II... >)
For a sequence [head,tail...) return the single head element.
Definition: integersequence.hh:53
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
template which always yields a false value
Definition: typetraits.hh:124
template which always yields a true value
Definition: typetraits.hh:134
Type free of internal references that T can be converted to.
Definition: typetraits.hh:532
Just an empty class.
Definition: typetraits.hh:55
Enable typedef if two types are interoperable.
Definition: typetraits.hh:81
Whether this type has a value of NaN.
Definition: typetraits.hh:212
Get entry of std::integer_sequence.
Definition: typetraits.hh:507
Check if a type is callable with ()-operator and given arguments.
Definition: typetraits.hh:162
Check if T is an integral constant or any type derived from std::integral_constant.
Definition: typetraits.hh:411
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed...
Definition: typetraits.hh:250
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:384
Checks whether two types are interoperable.
Definition: typetraits.hh:65
static constexpr bool value
True if either a conversion from T1 to T2 or vice versa exists.
Definition: typetraits.hh:70
typetrait to check that a class has begin() and end() members
Definition: typetraits.hh:273
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:194
Check if T derived from a std::tuple<...>
Definition: typetraits.hh:357
Check if T is a std::tuple<...>
Definition: typetraits.hh:329
Compute size of variadic type list.
Definition: typetraits.hh:435