17template <
typename Derived>
21#include <dune/common/hybridutilities.hh>
30concept Pointer = std::is_pointer_v<T> || std::is_same_v<T, std::nullptr_t>;
34struct is_tuple : std::false_type
43template <
typename... T>
44struct is_tuple<std::tuple<T...>> : std::true_type
55template <
class Tuple,
class Type>
56requires is_tuple<Tuple>::value
59 Dune::Hybrid::forEach(Dune::Hybrid::integralRange(Dune::index_constant<std::tuple_size_v<Tuple>>()), [&](
auto i) {
60 using currentType = std::remove_cvref_t<std::tuple_element_t<i, Tuple>>;
61 if constexpr (std::is_same_v<currentType, Type>)
75template <
typename Fun,
typename... Args>
86template <
typename T,
typename Tuple>
93struct hasType<T, std::tuple<>> : std::false_type
98struct hasType<T, T> : std::true_type
109template <
typename T,
typename U,
typename... Ts>
110struct hasType<T, std::tuple<U, Ts...>> : hasType<T, std::tuple<Ts...>>
114template <
typename T,
typename... Ts>
115struct hasType<T, std::tuple<T, Ts...>> : std::true_type
121template <
template <
typename...>
class,
typename...>
122struct isSpecialization : std::false_type
158template <
typename T,
typename Deleter>
159struct isUniquePtr<std::unique_ptr<T, Deleter>> : std::true_type
167 template <
typename U = T>
168 static auto test(
int) -> std::remove_reference<decltype(*std::declval<U>())>;
169 static auto test(...) -> std::remove_cv<T>;
184template <
template <
typename...>
class U,
typename... T>
185struct isSpecialization<U, U<T...>> : std::true_type
190template <
template <
typename,
auto...>
class Type,
typename>
191struct isSpecializationTypeAndNonTypes : std::false_type
195template <
template <
typename,
auto...>
class Type,
typename T,
auto... N>
196struct isSpecializationTypeAndNonTypes<Type, Type<T, N...>> : std::true_type
200template <
template <
auto,
typename...>
class Type,
typename>
201struct isSpecializationNonTypeAndTypes : std::false_type
205template <
template <
auto,
auto,
typename...>
class Type,
typename>
206struct isSpecializationNonTypeNonTypeAndTypes : std::false_type
220template <
template <
auto,
typename...>
class Type,
auto T,
typename... N>
221struct isSpecializationNonTypeAndTypes<Type, Type<T, N...>> : std::true_type
235template <
template <
auto,
auto,
typename...>
class Type,
auto T,
auto R,
typename... N>
236struct isSpecializationNonTypeNonTypeAndTypes<Type, Type<T, R, N...>> : std::true_type
241template <
template <
typename, auto,
typename>
class Type,
typename>
242struct isSpecializationTypeNonTypeAndType : std::false_type
256template <
template <
typename, auto,
typename>
class Type,
typename T,
auto M,
typename N>
257struct isSpecializationTypeNonTypeAndType<Type, Type<T, M, N>> : std::true_type
262template <
template <
auto...>
class Type,
typename>
263struct isSpecializationNonTypes : std::false_type
276template <
template <
auto...>
class Type,
auto... N>
277struct isSpecializationNonTypes<Type, Type<N...>> : std::true_type
298template <
class T,
class Tuple>
302struct Index<T, std::tuple<>>
304 static const std::size_t value = 0;
307template <
class T,
class... Types>
308struct Index<T, std::tuple<T, Types...>>
310 static constexpr std::size_t value = 0;
313template <
class T,
class U,
class... Types>
314struct Index<T, std::tuple<U, Types...>>
316 static const std::size_t value = 1 + Index<T, std::tuple<Types...>>::value;
337template <
class Container,
class NewType>
344template <
class OldType,
class... Args,
template <
class...>
class Container,
class NewType>
345struct Rebind<Container<OldType, Args...>, NewType>
347 using other = Container<NewType, typename Rebind<Args, NewType>::other...>;
353template <
class OldType, std::
size_t N,
template <
class, std::
size_t>
class Container,
class NewType>
354struct Rebind<Container<OldType, N>, NewType>
356 using other = Container<NewType, N>;
370template <
typename T,
typename =
void>
377template <
typename R,
typename... Args>
380 using return_type = R;
381 using ArgsTuple = std::tuple<Args...>;
382 using FreeSignature = R(Args...);
385 using args_type =
typename std::tuple_element<i, ArgsTuple>::type;
386 static constexpr int numberOfArguments =
sizeof...(Args);
392template <
typename R,
typename C,
typename... Args>
395 using return_type = R;
396 using ArgsTuple = std::tuple<Args...>;
397 using FreeSignature = R(Args...);
400 using args_type =
typename std::tuple_element<i, ArgsTuple>::type;
401 static constexpr int numberOfArguments =
sizeof...(Args);
407template <
typename R,
typename C,
typename... Args>
408struct FunctionTraits<R (C::*)(Args...)>
410 using return_type = R;
411 using ArgsTuple = std::tuple<Args...>;
412 using FreeSignature = R(Args...);
415 using args_type =
typename std::tuple_element<i, ArgsTuple>::type;
416 static constexpr int numberOfArguments =
sizeof...(Args);
424struct FunctionTraits<T,
Dune::void_t<decltype(&T::operator())>> :
public FunctionTraits<decltype(&T::operator())>
436template <
typename Tuple, std::
size_t Pos,
typename NewType>
440template <
typename NewType, std::size_t Pos,
typename... Args>
444 template <std::size_t... Is>
445 static auto replace_impl(std::index_sequence<Is...>) -> std::tuple<std::conditional_t<Is == Pos, NewType, Args>...>;
448 using type =
decltype(replace_impl(std::index_sequence_for<Args...>{}));
459template <
typename Tuple, std::
size_t Pos,
typename NewType>
468template <
typename R,
typename Tuple>
472template <
typename R,
typename... Args>
475 using type = std::function<R(Args...)>;
485template <
typename R,
typename Tuple>
495template <
typename Func, std::
size_t Pos,
typename NewType>
499template <
typename R,
typename... Args, std::size_t Pos,
typename NewType>
502 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:76
::value consteval int countType()
Metafunction to count the occurrences of a specific type in a tuple.
Definition: traits.hh:57
Definition: truncatedconjugategradient.hh:24
Definition: utils/concepts.hh:666
typename remove_pointer< T >::type remove_pointer_t
Definition: traits.hh:176
typename TupleToFunctionType< R, Tuple >::type TupleToFunctionType_t
Alias template for TupleToFunctionType.
Definition: traits.hh:486
typename ReplaceTypeAtPos< Tuple, Pos, NewType >::type ReplaceTypeAtPos_t
Alias template for ReplaceTypeAtPos.
Definition: traits.hh:460
Definition: utils/dirichletvalues.hh:30
Type trait to check if a specified type is present in a tuple.
Definition: traits.hh:88
Type trait to check if a type is a isSharedPtr.
Definition: traits.hh:136
Type trait to check if a type is a isUniquePtr.
Definition: traits.hh:153
Definition: traits.hh:166
typename decltype(test(0))::type type
Definition: traits.hh:172
Type trait to get the index of a type in a tuple.
Definition: traits.hh:299
Type trait to rebind the underlying type of containers.
Definition: traits.hh:338
Type trait for extracting information about functions.
Definition: traits.hh:371
Helper to replace the type at a specific position in a tuple.
Definition: traits.hh:437
Helper to convert a tuple to a function type.
Definition: traits.hh:469
Main function to wrap the type at position pos in a std::function.
Definition: traits.hh:496
Concept to check if a type is a pointer or nullptr_t.
Definition: traits.hh:30
Concept to check if a type is an Eigen SparseMatrix.
Definition: traits.hh:517