Skip to content

Commit 746a2bd

Browse files
[SYCL] Refactor vector_arith* (#16349)
This PR separates the "base" case functional implementation from templates/overloads/constraints. The latter doesn't match even the current SYCL spec and that is not taking into account proposed vec/swizzle changes. Making this change would allow to share more code between non-preview/preview implementation paths when implementing proposed SYCL vec/swizzle changes.
1 parent 5d8a552 commit 746a2bd

File tree

5 files changed

+395
-366
lines changed

5 files changed

+395
-366
lines changed

sycl/include/sycl/detail/type_traits.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,22 @@ struct map_type<T, From, To, Rest...> {
384384
template <typename T, typename... Ts>
385385
constexpr bool check_type_in_v = ((std::is_same_v<T, Ts> || ...));
386386

387+
#if __has_builtin(__type_pack_element)
388+
template <int N, typename... Ts>
389+
using nth_type_t = __type_pack_element<N, Ts...>;
390+
#else
391+
template <int N, typename T, typename... Ts> struct nth_type {
392+
using type = typename nth_type<N - 1, Ts...>::type;
393+
};
394+
395+
template <typename T, typename... Ts> struct nth_type<0, T, Ts...> {
396+
using type = T;
397+
};
398+
399+
template <int N, typename... Ts>
400+
using nth_type_t = typename nth_type<N, Ts...>::type;
401+
#endif
402+
387403
} // namespace detail
388404
} // namespace _V1
389405
} // namespace sycl

0 commit comments

Comments
 (0)