6 #ifndef THEORETICA_CORE_TRAITS_H
7 #define THEORETICA_CORE_TRAITS_H
20 template<
typename ...Args>
22 template<
typename ...Args>
23 using void_t =
typename make_void<Args...>::type;
29 template<
typename Type>
40 template<
typename Structure,
typename = _
internal::
void_t<>>
45 template<
typename Structure>
47 <Structure, _internal::void_t<
48 decltype(std::declval<Structure>() < std::declval<Structure>())>
54 template<
typename Structure,
typename = _
internal::
void_t<>>
58 template<
typename Structure>
60 <Structure, _internal::void_t<
61 decltype(std::declval<Structure>()[0])>
67 template<
typename Structure,
typename = _
internal::
void_t<>>
71 template<
typename Structure>
73 <Structure, _internal::void_t<
74 decltype(std::declval<Structure>().begin())>
80 template<
typename Structure,
typename = _
internal::
void_t<>>
83 template<
typename Structure>
85 <Structure, _internal::void_t<
86 decltype(std::declval<Structure>()[0]),
87 decltype(std::declval<Structure>().size())>
94 template<
typename Structure,
typename = _
internal::
void_t<>>
98 template<
typename Structure>
100 <Structure, _internal::void_t<
101 decltype(std::declval<Structure>()(0, 0)),
102 decltype(std::declval<Structure>().rows()),
103 decltype(std::declval<Structure>().cols())>
104 > : std::true_type{};
108 namespace _internal {
111 template<
typename Structure,
typename =
void>
117 template<
typename Structure>
119 <Structure, _internal::void_t<decltype(std::declval<Structure&>()[0])>> {
120 using type = std::remove_reference_t<decltype(std::declval<Structure>()[0])>;
126 template<
typename Structure>
128 typename _internal::vector_element_or_void<Structure>::type;
132 template<
typename Structure>
134 std::remove_reference_t<decltype(std::declval<Structure>()[0])>;
138 template<
typename Structure>
140 std::remove_reference_t<decltype(std::declval<Structure>()(0, 0))>;
145 template<
typename Structure,
typename Type>
147 : std::is_same<vector_element_t<Structure>, Type> {};
152 template<
typename Structure>
159 template<
typename Structure,
typename T =
bool>
166 template<
typename Structure,
typename T =
bool>
171 template<
typename Function>
175 template<
typename Function,
typename... Args>
177 using type = std::tuple<Args...>;
181 namespace _internal {
184 template<
typename Function,
typename T,
typename =
void>
190 template<
typename Function,
typename T>
192 <Function, T, _internal::void_t<decltype(std::declval<Function>()(T(0.0)))>> {
193 using type = decltype(std::declval<Function>()(T(0.0)));
201 template<
class ReturnType,
class... Args>
204 using return_type = ReturnType;
205 using args_type = std::tuple<Args...>;
208 template<
class ReturnType,
class... Args>
211 using return_type = ReturnType;
212 using args_type = std::tuple<Args...>;
215 template<
class Class,
class ReturnType,
class... Args>
218 using return_type = ReturnType;
219 using args_type = std::tuple<Args...>;
226 template<
typename Function>
230 typename _internal::return_type_or_void<Function, real>::type
232 std::true_type, std::false_type
238 template<
typename Function,
typename T =
bool>
240 typename std::enable_if_t<is_real_func<Function>::value, T>;
245 template<
typename Function>
Mathematical constants and default algorithm parameters.
Main namespace of the library which contains all functions and objects.
Definition: algebra.h:27
double real
A real number, defined as a floating point type.
Definition: constants.h:188
typename std::enable_if_t< is_real_func< Function >::value, T > enable_real_func
Enable a certain function overload if the given type is a function taking as first argument a real nu...
Definition: core_traits.h:240
typename _internal::func_helper< Function >::return_type return_type_t
Extract the return type of a Callable object, such as a function pointer or lambda function.
Definition: core_traits.h:246
std::remove_reference_t< decltype(std::declval< Structure >()(0, 0))> matrix_element_t
Extract the type of a matrix (or any doubly indexable container) from its operator().
Definition: core_traits.h:140
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition: core_traits.h:134
std::enable_if_t< is_vector< Structure >::value, T > enable_vector
Enable a function overload if the template typename is considerable a vector.
Definition: core_traits.h:167
typename _internal::vector_element_or_void< Structure >::type vector_element_or_void_t
Extract the type of a vector (or any indexable container) from its operator[], returning void if the ...
Definition: core_traits.h:128
std::conditional_t< is_real_type< typename _internal::return_type_or_void< Function, real >::type >::value, std::true_type, std::false_type > is_real_func
Type trait to check whether the given function takes a real number as its first argument.
Definition: core_traits.h:233
std::enable_if_t< is_matrix< Structure >::value, T > enable_matrix
Enable a function overload if the template typename is considerable a matrix.
Definition: core_traits.h:160
Definition: core_traits.h:199
Definition: core_traits.h:21
Definition: core_traits.h:185
Helper structure for vector_element_t.
Definition: core_traits.h:112
Type trait to check whether an indexable container has elements of the given type.
Definition: core_traits.h:147
Check whether a structure is indexable by a single integer index, by checking that it has the operato...
Definition: core_traits.h:55
Check whether a structure is iterable, by checking that it has a method begin().
Definition: core_traits.h:68
Check whether a structure is considerable a matrix, by checking that it has an operator(),...
Definition: core_traits.h:95
Check whether a structure is orderable, by checking that it has a comparison operator<().
Definition: core_traits.h:41
Type trait to check whether a type represents a real number.
Definition: core_traits.h:30
Check whether a structure is considerable a vector, by checking that it has an operator[] and a size(...
Definition: core_traits.h:81