diff --git a/sycl/include/sycl/vector_preview.hpp b/sycl/include/sycl/vector_preview.hpp index e96d64b8a930e..f24919377d97b 100644 --- a/sycl/include/sycl/vector_preview.hpp +++ b/sycl/include/sycl/vector_preview.hpp @@ -856,14 +856,21 @@ class SwizzleOp { #error "Undefine __SYCL_OPASSIGN macro." #endif #define __SYCL_OPASSIGN(OPASSIGN, OP) \ - SwizzleOp &operator OPASSIGN(const DataT & Rhs) { \ - operatorHelper(vec_t(Rhs)); \ - return *this; \ + friend const SwizzleOp &operator OPASSIGN(const SwizzleOp & Lhs, \ + const DataT & Rhs) { \ + Lhs.operatorHelper(vec_t(Rhs)); \ + return Lhs; \ } \ template \ - SwizzleOp &operator OPASSIGN(const RhsOperation & Rhs) { \ - operatorHelper(Rhs); \ - return *this; \ + friend const SwizzleOp &operator OPASSIGN(const SwizzleOp & Lhs, \ + const RhsOperation & Rhs) { \ + Lhs.operatorHelper(Rhs); \ + return Lhs; \ + } \ + friend const SwizzleOp &operator OPASSIGN(const SwizzleOp & Lhs, \ + const vec_t & Rhs) { \ + Lhs.operatorHelper(Rhs); \ + return Lhs; \ } __SYCL_OPASSIGN(+=, std::plus) @@ -882,13 +889,13 @@ class SwizzleOp { #error "Undefine __SYCL_UOP macro" #endif #define __SYCL_UOP(UOP, OPASSIGN) \ - SwizzleOp &operator UOP() { \ - *this OPASSIGN static_cast(1); \ - return *this; \ + friend const SwizzleOp &operator UOP(const SwizzleOp & sv) { \ + sv OPASSIGN static_cast(1); \ + return sv; \ } \ - vec_t operator UOP(int) { \ - vec_t Ret = *this; \ - *this OPASSIGN static_cast(1); \ + friend vec_t operator UOP(const SwizzleOp &sv, int) { \ + vec_t Ret = sv; \ + sv OPASSIGN static_cast(1); \ return Ret; \ } @@ -1429,7 +1436,7 @@ class SwizzleOp { } template