@@ -125,11 +125,23 @@ template <typename T> class GetOp {
125
125
//
126
126
// must go throw `v.x()` returning a swizzle, then its `operator==` returning
127
127
// vec<int, 1> and we want that code to compile.
128
- template <typename Self> class ScalarConversionOperatorMixIn {
129
- using T = typename from_incomplete<Self>::element_type;
128
+ template <typename Self> class ScalarConversionOperatorsMixIn {
129
+ using element_type = typename from_incomplete<Self>::element_type;
130
130
131
131
public:
132
- operator T () const { return (*static_cast <const Self *>(this ))[0 ]; }
132
+ operator element_type () const {
133
+ return (*static_cast <const Self *>(this ))[0 ];
134
+ }
135
+
136
+ #if !__SYCL_USE_LIBSYCL8_VEC_IMPL
137
+ template <
138
+ typename T, typename = std::enable_if_t <!std::is_same_v<T, element_type>>,
139
+ typename =
140
+ std::void_t <decltype (static_cast <T>(std::declval<element_type>()))>>
141
+ explicit operator T () const {
142
+ return static_cast <T>((*static_cast <const Self *>(this ))[0 ]);
143
+ }
144
+ #endif
133
145
};
134
146
135
147
template <typename T>
@@ -310,7 +322,7 @@ class __SYCL_EBO vec
310
322
: public detail::vec_arith<DataT, NumElements>,
311
323
public detail::ApplyIf<
312
324
NumElements == 1 ,
313
- detail::ScalarConversionOperatorMixIn <vec<DataT, NumElements>>>,
325
+ detail::ScalarConversionOperatorsMixIn <vec<DataT, NumElements>>>,
314
326
public detail::NamedSwizzlesMixinBoth<vec<DataT, NumElements>>,
315
327
// Keep it last to simplify ABI layout test:
316
328
public detail::vec_base<DataT, NumElements> {
0 commit comments