14#include <dune/common/hybridutilities.hh>
23 concept Pointer = std::is_pointer_v<T> || std::is_same_v<T, std::nullptr_t>;
27 struct is_tuple : std::false_type {};
34 template <
typename... T>
35 struct is_tuple<std::tuple<T...>> : std::true_type {};
44 template <
class Tuple,
class Type>
45 requires is_tuple<Tuple>::value
consteval int countType() {
47 Dune::Hybrid::forEach(Dune::Hybrid::integralRange(Dune::index_constant<std::tuple_size_v<Tuple>>()), [&](
auto i) {
48 using currentType = std::remove_cvref_t<std::tuple_element_t<i, Tuple>>;
49 if constexpr (std::is_same_v<currentType, Type>) ++count;
62 template <
typename Fun,
typename... Args>
73 template <
typename T,
typename Tuple>
78 struct hasType<T, std::tuple<>> : std::false_type {};
81 struct hasType<T, T> : std::true_type {};
90 template <
typename T,
typename U,
typename... Ts>
91 struct hasType<T, std::tuple<U, Ts...>> : hasType<T, std::tuple<Ts...>> {};
93 template <
typename T,
typename... Ts>
94 struct hasType<T, std::tuple<T, Ts...>> : std::true_type {};
98 template <
template <
typename...>
class,
typename...>
99 struct isSpecialization : std::false_type {};
108 template <
template <
typename...>
class U,
typename... T>
109 struct isSpecialization<U, U<T...>> : std::true_type {};
112 template <
template <
typename,
auto...>
class Type,
typename>
113 struct isSpecializationTypeAndNonTypes : std::false_type {};
115 template <
template <
typename,
auto...>
class Type,
typename T,
auto... N>
116 struct isSpecializationTypeAndNonTypes<Type, Type<T, N...>> : std::true_type {};
118 template <
template <
auto,
typename...>
class Type,
typename>
119 struct isSpecializationNonTypeAndTypes : std::false_type {};
131 template <
template <
auto,
typename...>
class Type,
auto T,
typename... N>
132 struct isSpecializationNonTypeAndTypes<Type, Type<T, N...>> : std::true_type {};
135 template <
template <
typename, auto,
typename>
class Type,
typename>
136 struct isSpecializationTypeNonTypeAndType : std::false_type {};
148 template <
template <
typename, auto,
typename>
class Type,
typename T,
auto M,
typename N>
149 struct isSpecializationTypeNonTypeAndType<Type, Type<T, M, N>> : std::true_type {};
152 template <
template <
auto...>
class Type,
typename>
153 struct isSpecializationNonTypes : std::false_type {};
164 template <
template <
auto...>
class Type,
auto... N>
165 struct isSpecializationNonTypes<Type, Type<N...>> : std::true_type {};
184 template <
class T,
class Tuple>
188 struct Index<T, std::tuple<>> {
189 static const std::size_t value = 0;
192 template <
class T,
class... Types>
193 struct Index<T, std::tuple<T, Types...>> {
194 static constexpr std::size_t value = 0;
197 template <
class T,
class U,
class... Types>
198 struct Index<T, std::tuple<U, Types...>> {
199 static const std::size_t value = 1 + Index<T, std::tuple<Types...>>::value;
220 template <
class Container,
class NewType>
227 template <
class OldType,
class... Args,
template <
class...>
class Container,
class NewType>
228 struct Rebind<Container<OldType, Args...>, NewType> {
229 using other = Container<NewType, typename Rebind<Args, NewType>::other...>;
235 template <
class OldType, std::
size_t N,
template <
class, std::
size_t>
class Container,
class NewType>
236 struct Rebind<Container<OldType, N>, NewType> {
237 using other = Container<NewType, N>;
251 template <
typename T,
typename =
void>
258 template <
typename R,
typename... Args>
260 using return_type = R;
262 using args_type =
typename std::tuple_element<i, std::tuple<Args...>>::type;
263 static constexpr int numberOfArguments =
sizeof...(Args);
269 template <
typename R,
typename C,
typename... Args>
271 using return_type = R;
273 using args_type =
typename std::tuple_element<i, std::tuple<Args...>>::type;
274 static constexpr int numberOfArguments =
sizeof...(Args);
280 template <
typename R,
typename C,
typename... Args>
281 struct FunctionTraits<R (C::*)(Args...)> {
282 using return_type = R;
284 using args_type =
typename std::tuple_element<i, std::tuple<Args...>>::type;
285 static constexpr int numberOfArguments =
sizeof...(Args);
292 template <
typename T>
293 struct FunctionTraits<T,
Dune::void_t<decltype(&T::operator())>> :
public FunctionTraits<decltype(&T::operator())> {};
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:63
::value consteval int countType()
Metafunction to count the occurrences of a specific type in a tuple.
Definition: traits.hh:45
Definition: resultevaluators.hh:17
Type trait to check if a specified type is present in a tuple.
Definition: traits.hh:74
Type trait to get the index of a type in a tuple.
Definition: traits.hh:185
Type trait to rebind the underlying type of containers.
Definition: traits.hh:221
Type trait for extracting information about functions.
Definition: traits.hh:252
Concept to check if a type is a pointer or nullptr_t.
Definition: traits.hh:23