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
401 template<
typename... T>
403 :
public std::integral_constant<std::size_t,sizeof...(T)>
411 template<
class T, T...>
412 struct IntegerSequenceHelper;
420 template<
class T, T head, T... tail>
421 struct IntegerSequenceHelper<T, head, tail...>
425 static constexpr auto get(std::integral_constant<std::size_t, 0>)
427 return std::integral_constant<T, head>();
431 template<std::size_t index,
432 std::enable_if_t<(index > 0) and (index <
sizeof...(tail)+1),
int> = 0>
433 static constexpr auto get(std::integral_constant<std::size_t, index>)
435 return IntegerSequenceHelper<T, tail...>::get(std::integral_constant<std::size_t, index-1>());
439 template<std::size_t index,
440 std::enable_if_t<(index >=
sizeof...(tail)+1),
int> = 0>
441 static constexpr auto get(std::integral_constant<std::size_t, index>)
443 static_assert(index <
sizeof...(tail)+1,
"index used in IntegerSequenceEntry exceed size");
461 template<
class T, T... t, std::size_t index>
462 constexpr auto integerSequenceEntry(std::integer_sequence<T, t...> , std::integral_constant<std::size_t, index> i)
464 static_assert(index <
sizeof...(t),
"index used in IntegerSequenceEntry exceed size");
465 return Impl::IntegerSequenceHelper<T, t...>::get(i);
475 template<
class IntegerSequence, std::
size_t index>
480 template<
class T, T... t, std::size_t i>
482 :
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:462
typename FieldTraits< Type >::real_type real_t
Convenient access to FieldTraits<Type>::real_type.
Definition: typetraits.hh:301
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition: typetraits.hh:642
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition: typetraits.hh:558
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
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:501
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:476
Check if a type is callable with ()-operator and given arguments.
Definition: typetraits.hh:162
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:404