@@ -125,11 +125,23 @@ template <typename T> class GetOp {
125125//
126126// must go throw `v.x()` returning a swizzle, then its `operator==` returning
127127// 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;
130130
131131public:
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
133145};
134146
135147template <typename T>
@@ -310,7 +322,7 @@ class __SYCL_EBO vec
310322 : public detail::vec_arith<DataT, NumElements>,
311323 public detail::ApplyIf<
312324 NumElements == 1 ,
313- detail::ScalarConversionOperatorMixIn <vec<DataT, NumElements>>>,
325+ detail::ScalarConversionOperatorsMixIn <vec<DataT, NumElements>>>,
314326 public detail::NamedSwizzlesMixinBoth<vec<DataT, NumElements>>,
315327 // Keep it last to simplify ABI layout test:
316328 public detail::vec_base<DataT, NumElements> {
0 commit comments