Skip to content

Commit 33e5b10

Browse files
lbushi25bader
andauthored
[SYCL] Add value_type alias to sycl::vec class (#12960)
This PR adds the value_type alias for the data type of a sycl::vec object as described in the spec. --------- Co-authored-by: Alexey Bader <[email protected]>
1 parent 9e930b4 commit 33e5b10

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,9 @@ template <typename T, typename Enable = void> struct RelConverter {
518518
template <typename T> class TryToGetElementType {
519519
static T check(...);
520520
template <typename A> static typename A::element_type check(const A &);
521-
template <typename A> static typename A::value_type check(const A &);
521+
template <typename A, typename = std::enable_if_t<!std::is_same_v<
522+
typename A::element_type, typename A::value_type>>>
523+
static typename A::value_type check(const A &);
522524

523525
public:
524526
using type = decltype(check(T()));

sycl/include/sycl/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ template <typename Type, int NumElements> class vec {
546546

547547
public:
548548
using element_type = DataT;
549+
using value_type = DataT;
549550
using rel_t = detail::rel_t<DataT>;
550-
551551
#ifdef __SYCL_DEVICE_ONLY__
552552
#if defined(__INTEL_PREVIEW_BREAKING_CHANGES)
553553
using vector_t =
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clangxx -fsycl -fsyntax-only %s
2+
#include <sycl/sycl.hpp>
3+
#include <type_traits>
4+
using namespace std;
5+
int main() {
6+
static_assert(is_same_v<sycl::vec<int, 1>::value_type, int>);
7+
static_assert(is_same_v<sycl::vec<float, 2>::value_type, float>);
8+
static_assert(is_same_v<sycl::vec<double, 3>::value_type, double>);
9+
static_assert(is_same_v<sycl::vec<sycl::half, 4>::value_type, sycl::half>);
10+
return 0;
11+
}

0 commit comments

Comments
 (0)