Skip to content

Commit 65939a6

Browse files
committed
Change how invoke_impl is implemented
1 parent ef4c0f9 commit 65939a6

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

include/kernel_float/apply.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ using default_policy = accurate_policy;
168168

169169
namespace detail {
170170

171-
template<typename F, typename Output, typename... Args>
171+
template<typename F, typename... Args>
172172
struct invoke_impl {
173-
KERNEL_FLOAT_INLINE static Output call(F fun, Args... args) {
173+
KERNEL_FLOAT_INLINE static auto call(F fun, Args... args) {
174174
return fun(args...);
175175
}
176176
};
@@ -190,7 +190,7 @@ struct apply_impl<accurate_policy, F, N, Output, Args...> {
190190
KERNEL_FLOAT_INLINE static void call(F fun, Output* output, const Args*... args) {
191191
#pragma unroll
192192
for (size_t i = 0; i < N; i++) {
193-
output[i] = invoke_impl<F, Output, Args...>::call(fun, args[i]...);
193+
output[i] = invoke_impl<F, Args...>::call(fun, args[i]...);
194194
}
195195
}
196196
};
@@ -225,6 +225,10 @@ using default_map_impl = map_impl<default_policy, F, N, Output, Args...>;
225225

226226
} // namespace detail
227227

228+
template<typename F, typename... Args>
229+
using result_t = decltype(
230+
detail::invoke_impl<F, Args...>::call(detail::declval<F>(), detail::declval<Args>()...));
231+
228232
template<typename F, typename... Args>
229233
using map_type =
230234
vector<result_t<F, vector_value_type<Args>...>, broadcast_vector_extent_type<Args...>>;

include/kernel_float/meta.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ struct is_implicit_convertible_impl {
236236
static constexpr bool value = false;
237237
};
238238

239+
// This has to be done using SFINAE since `promote_type<From, To>` might actually be undefined if `From` is not
240+
// implicitly convertible to `To`.
239241
template<typename From, typename To>
240242
struct is_implicit_convertible_impl<From, To, typename promote_type<From, To>::type> {
241243
static constexpr bool value = true;
@@ -254,9 +256,6 @@ KERNEL_FLOAT_INLINE T& declval() {
254256
}
255257
} // namespace detail
256258

257-
template<typename F, typename... Args>
258-
using result_t = decltype((detail::declval<F>())(detail::declval<Args>()...));
259-
260259
namespace detail {
261260
template<bool, typename T>
262261
struct enable_if_impl {};

single_include/kernel_float.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
//================================================================================
1818
// this file has been auto-generated, do not modify its contents!
19-
// date: 2025-07-17 14:58:12.821069
20-
// git hash: cb04a8f36c97ea0e0ff0648316f82b6125214c83
19+
// date: 2025-08-12 09:36:07.217735
20+
// git hash: 15a92ee9e96aef3147fdcfc3dcb3bd4ce501d063
2121
//================================================================================
2222

2323
#ifndef KERNEL_FLOAT_MACROS_H
@@ -340,6 +340,8 @@ struct is_implicit_convertible_impl {
340340
static constexpr bool value = false;
341341
};
342342

343+
// This has to be done using SFINAE since `promote_type<From, To>` might actually be undefined if `From` is not
344+
// implicitly convertible to `To`.
343345
template<typename From, typename To>
344346
struct is_implicit_convertible_impl<From, To, typename promote_type<From, To>::type> {
345347
static constexpr bool value = true;
@@ -358,9 +360,6 @@ KERNEL_FLOAT_INLINE T& declval() {
358360
}
359361
} // namespace detail
360362

361-
template<typename F, typename... Args>
362-
using result_t = decltype((detail::declval<F>())(detail::declval<Args>()...));
363-
364363
namespace detail {
365364
template<bool, typename T>
366365
struct enable_if_impl {};
@@ -834,9 +833,9 @@ using default_policy = accurate_policy;
834833

835834
namespace detail {
836835

837-
template<typename F, typename Output, typename... Args>
836+
template<typename F, typename... Args>
838837
struct invoke_impl {
839-
KERNEL_FLOAT_INLINE static Output call(F fun, Args... args) {
838+
KERNEL_FLOAT_INLINE static auto call(F fun, Args... args) {
840839
return fun(args...);
841840
}
842841
};
@@ -856,7 +855,7 @@ struct apply_impl<accurate_policy, F, N, Output, Args...> {
856855
KERNEL_FLOAT_INLINE static void call(F fun, Output* output, const Args*... args) {
857856
#pragma unroll
858857
for (size_t i = 0; i < N; i++) {
859-
output[i] = invoke_impl<F, Output, Args...>::call(fun, args[i]...);
858+
output[i] = invoke_impl<F, Args...>::call(fun, args[i]...);
860859
}
861860
}
862861
};
@@ -891,6 +890,10 @@ using default_map_impl = map_impl<default_policy, F, N, Output, Args...>;
891890

892891
} // namespace detail
893892

893+
template<typename F, typename... Args>
894+
using result_t = decltype(
895+
detail::invoke_impl<F, Args...>::call(detail::declval<F>(), detail::declval<Args>()...));
896+
894897
template<typename F, typename... Args>
895898
using map_type =
896899
vector<result_t<F, vector_value_type<Args>...>, broadcast_vector_extent_type<Args...>>;

0 commit comments

Comments
 (0)