@@ -58,7 +58,7 @@ struct apply_scalar_unary<F, T, require_eigen_t<T>> {
58
58
* @return Componentwise application of the function specified
59
59
* by F to the specified matrix.
60
60
*/
61
- static inline auto apply (const T & x) {
61
+ static inline auto apply (const std:: decay_t <T> & x) {
62
62
return x.unaryExpr ([](auto && x) {
63
63
return apply_scalar_unary<F, std::decay_t <decltype (x)>>::apply (x);
64
64
});
@@ -69,7 +69,7 @@ struct apply_scalar_unary<F, T, require_eigen_t<T>> {
69
69
* expression template of type T.
70
70
*/
71
71
using return_t = std::decay_t <decltype(
72
- apply_scalar_unary<F, T >::apply(std::declval<T>()))>;
72
+ apply_scalar_unary<F, std:: decay_t <T> >::apply(std::declval<T>()))>;
73
73
};
74
74
75
75
/* *
@@ -83,7 +83,8 @@ struct apply_scalar_unary<F, T, require_floating_point_t<T>> {
83
83
/* *
84
84
* The return type, double.
85
85
*/
86
- using return_t = std::decay_t <decltype(F::fun(std::declval<T>()))>;
86
+ using return_t
87
+ = std::decay_t <decltype(F::fun(std::declval<std::decay_t <T>>()))>;
87
88
88
89
/* *
89
90
* Apply the function specified by F to the specified argument.
@@ -114,11 +115,12 @@ struct apply_scalar_unary<F, T, require_complex_t<T>> {
114
115
* @param x Argument scalar.
115
116
* @return Result of applying F to the scalar.
116
117
*/
117
- static inline auto apply (const T & x) { return F::fun (x); }
118
+ static inline auto apply (const std:: decay_t <T> & x) { return F::fun (x); }
118
119
/* *
119
120
* The return type
120
121
*/
121
- using return_t = std::decay_t <decltype(F::fun(std::declval<T>()))>;
122
+ using return_t
123
+ = std::decay_t <decltype(F::fun(std::declval<std::decay_t <T>>()))>;
122
124
};
123
125
124
126
/* *
@@ -157,13 +159,13 @@ struct apply_scalar_unary<F, T, require_integral_t<T>> {
157
159
* @tparam T Type of element contained in standard vector.
158
160
*/
159
161
template <typename F, typename T>
160
- struct apply_scalar_unary <F, std::vector <T>> {
162
+ struct apply_scalar_unary <F, T, require_std_vector_t <T>> {
161
163
/* *
162
164
* Return type, which is calculated recursively as a standard
163
165
* vector of the return type of the contained type T.
164
166
*/
165
- using return_t = typename std::vector<
166
- plain_type_t < typename apply_scalar_unary<F, T >::return_t >>;
167
+ using return_t = typename std::vector<plain_type_t <
168
+ typename apply_scalar_unary<F, value_type_t <std:: decay_t <T>> >::return_t >>;
167
169
168
170
/* *
169
171
* Apply the function specified by F elementwise to the
@@ -174,10 +176,10 @@ struct apply_scalar_unary<F, std::vector<T>> {
174
176
* @return Elementwise application of F to the elements of the
175
177
* container.
176
178
*/
177
- static inline auto apply (const std::vector <T>& x) {
179
+ static inline auto apply (const std::decay_t <T>& x) {
178
180
return_t fx (x.size ());
179
181
for (size_t i = 0 ; i < x.size (); ++i) {
180
- fx[i] = apply_scalar_unary<F, T >::apply (x[i]);
182
+ fx[i] = apply_scalar_unary<F, value_type_t <T> >::apply (x[i]);
181
183
}
182
184
return fx;
183
185
}
0 commit comments