19#include <dune/common/hybridutilities.hh>
28concept Pointer = std::is_pointer_v<T> || std::is_same_v<T, std::nullptr_t>;
32struct is_tuple : std::false_type
41template <
typename... T>
42struct is_tuple<
std::tuple<T...>> : std::true_type
53template <
class Tuple,
class Type>
54requires is_tuple<Tuple>::value
57 Dune::Hybrid::forEach(Dune::Hybrid::integralRange(Dune::index_constant<std::tuple_size_v<Tuple>>()), [&](
auto i) {
58 using currentType = std::remove_cvref_t<std::tuple_element_t<i, Tuple>>;
59 if constexpr (std::is_same_v<currentType, Type>)
73template <
typename Fun,
typename... Args>
84template <
typename T,
typename Tuple>
91struct hasType<T,
std::tuple<>> : std::false_type
96struct hasType<T, T> : std::true_type
107template <
typename T,
typename U,
typename... Ts>
108struct hasType<T,
std::tuple<U, Ts...>> : hasType<T, std::tuple<Ts...>>
112template <
typename T,
typename... Ts>
113struct hasType<T,
std::tuple<T, Ts...>> : std::true_type
119template <
template <
typename...>
class,
typename...>
120struct isSpecialization : std::false_type
147 template <
typename U = T>
148 static auto test(
int) -> std::remove_reference<decltype(*std::declval<U>())>;
149 static auto test(...) -> std::remove_cv<T>;
164template <
template <
typename...>
class U,
typename... T>
165struct isSpecialization<U, U<T...>> : std::true_type
170template <
template <
typename,
auto...>
class Type,
typename>
171struct isSpecializationTypeAndNonTypes : std::false_type
175template <
template <
typename,
auto...>
class Type,
typename T,
auto... N>
176struct isSpecializationTypeAndNonTypes<Type, Type<T, N...>> : std::true_type
180template <
template <
auto,
typename...>
class Type,
typename>
181struct isSpecializationNonTypeAndTypes : std::false_type
195template <
template <
auto,
typename...>
class Type,
auto T,
typename... N>
196struct isSpecializationNonTypeAndTypes<Type, Type<T, N...>> : std::true_type
201template <
template <
typename, auto,
typename>
class Type,
typename>
202struct isSpecializationTypeNonTypeAndType : std::false_type
216template <
template <
typename, auto,
typename>
class Type,
typename T,
auto M,
typename N>
217struct isSpecializationTypeNonTypeAndType<Type, Type<T, M, N>> : std::true_type
222template <
template <
auto...>
class Type,
typename>
223struct isSpecializationNonTypes : std::false_type
236template <
template <
auto...>
class Type,
auto... N>
237struct isSpecializationNonTypes<Type, Type<N...>> : std::true_type
258template <
class T,
class Tuple>
264 static const std::size_t value = 0;
267template <
class T,
class... Types>
268struct Index<T,
std::tuple<T, Types...>>
270 static constexpr std::size_t value = 0;
273template <
class T,
class U,
class... Types>
274struct Index<T,
std::tuple<U, Types...>>
276 static const std::size_t value = 1 + Index<T, std::tuple<Types...>>::value;
297template <
class Container,
class NewType>
304template <
class OldType,
class... Args,
template <
class...>
class Container,
class NewType>
305struct Rebind<Container<OldType, Args...>, NewType>
307 using other = Container<NewType, typename Rebind<Args, NewType>::other...>;
313template <
class OldType, std::
size_t N,
template <
class, std::
size_t>
class Container,
class NewType>
314struct Rebind<Container<OldType, N>, NewType>
316 using other = Container<NewType, N>;
330template <
typename T,
typename =
void>
337template <
typename R,
typename... Args>
340 using return_type = R;
341 using ArgsTuple = std::tuple<Args...>;
344 using args_type =
typename std::tuple_element<i, ArgsTuple>::type;
345 static constexpr int numberOfArguments =
sizeof...(Args);
351template <
typename R,
typename C,
typename... Args>
354 using return_type = R;
355 using ArgsTuple = std::tuple<Args...>;
358 using args_type =
typename std::tuple_element<i, ArgsTuple>::type;
359 static constexpr int numberOfArguments =
sizeof...(Args);
365template <
typename R,
typename C,
typename... Args>
366struct FunctionTraits<R (C::*)(Args...)>
368 using return_type = R;
369 using ArgsTuple = std::tuple<Args...>;
372 using args_type =
typename std::tuple_element<i, ArgsTuple>::type;
373 static constexpr int numberOfArguments =
sizeof...(Args);
381struct FunctionTraits<T,
Dune::void_t<decltype(&T::operator())>> :
public FunctionTraits<decltype(&T::operator())>
393template <
typename Tuple, std::
size_t Pos,
typename NewType>
397template <
typename NewType, std::size_t Pos,
typename... Args>
401 template <std::size_t... Is>
402 static auto replace_impl(std::index_sequence<Is...>) -> std::tuple<std::conditional_t<Is == Pos, NewType, Args>...>;
405 using type =
decltype(replace_impl(std::index_sequence_for<Args...>{}));
416template <
typename Tuple, std::
size_t Pos,
typename NewType>
425template <
typename R,
typename Tuple>
429template <
typename R,
typename... Args>
432 using type = std::function<R(Args...)>;
442template <
typename R,
typename Tuple>
452template <
typename Func, std::
size_t Pos,
typename NewType>
456template <
typename R,
typename... Args, std::size_t Pos,
typename NewType>
459 using OriginalFunction = std::function<R(Args...)>;
std::invoke_result_t< Fun, Args... > ReturnType
Type trait to obtain the return type of a callable type when given specific arguments.
Definition: traits.hh:74
::value consteval int countType()
Metafunction to count the occurrences of a specific type in a tuple.
Definition: traits.hh:55
Definition: utils/dirichletvalues.hh:30
typename remove_pointer< T >::type remove_pointer_t
Definition: traits.hh:156
typename TupleToFunctionType< R, Tuple >::type TupleToFunctionType_t
Alias template for TupleToFunctionType.
Definition: traits.hh:443
typename ReplaceTypeAtPos< Tuple, Pos, NewType >::type ReplaceTypeAtPos_t
Alias template for ReplaceTypeAtPos.
Definition: traits.hh:417
Type trait to check if a specified type is present in a tuple.
Definition: traits.hh:86
Type trait to check if a type is a isSharedPtr.
Definition: traits.hh:134
Definition: traits.hh:146
typename decltype(test(0))::type type
Definition: traits.hh:152
Type trait to get the index of a type in a tuple.
Definition: traits.hh:259
Type trait to rebind the underlying type of containers.
Definition: traits.hh:298
Type trait for extracting information about functions.
Definition: traits.hh:331
Helper to replace the type at a specific position in a tuple.
Definition: traits.hh:394
Helper to convert a tuple to a function type.
Definition: traits.hh:426
Main function to wrap the type at position pos in a std::function.
Definition: traits.hh:453
Concept to check if a type is a pointer or nullptr_t.
Definition: traits.hh:28