diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h index 706b9aa3a7..582a359fbd 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_vector_types.h @@ -144,22 +144,40 @@ THE SOFTWARE. return *this; } + // TODO: convertibility is too restrictive, constraint should be on + // the operator being invocable with a value of type U. + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator+=(T x) noexcept { + Scalar_accessor& operator+=(U x) noexcept { data[idx] += x; return *this; } + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator-=(T x) noexcept { + Scalar_accessor& operator-=(U x) noexcept { data[idx] -= x; return *this; } + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator*=(T x) noexcept { + Scalar_accessor& operator*=(U x) noexcept { data[idx] *= x; return *this; } + template< + typename U, + typename std::enable_if< + std::is_convertible{}>::type* = nullptr> __host__ __device__ Scalar_accessor& operator/=(T x) noexcept { data[idx] /= x; @@ -167,50 +185,56 @@ THE SOFTWARE. } template< typename U = T, - typename std::enable_if{}>::type* = nullptr> + typename std::enable_if{} && + std::is_integral{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator%=(T x) noexcept { + Scalar_accessor& operator%=(U x) noexcept { data[idx] %= x; return *this; } template< typename U = T, - typename std::enable_if{}>::type* = nullptr> + typename std::enable_if{} && + std::is_integral{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator>>=(T x) noexcept { + Scalar_accessor& operator>>=(U x) noexcept { data[idx] >>= x; return *this; } template< typename U = T, - typename std::enable_if{}>::type* = nullptr> + typename std::enable_if{} && + std::is_integral{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator<<=(T x) noexcept { + Scalar_accessor& operator<<=(U x) noexcept { data[idx] <<= x; return *this; } template< typename U = T, - typename std::enable_if{}>::type* = nullptr> + typename std::enable_if{} && + std::is_integral{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator&=(T x) noexcept { + Scalar_accessor& operator&=(U x) noexcept { data[idx] &= x; return *this; } template< typename U = T, - typename std::enable_if{}>::type* = nullptr> + typename std::enable_if{} && + std::is_integral{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator|=(T x) noexcept { + Scalar_accessor& operator|=(U x) noexcept { data[idx] |= x; return *this; } template< typename U = T, - typename std::enable_if{}>::type* = nullptr> + typename std::enable_if{} && + std::is_integral{}>::type* = nullptr> __host__ __device__ - Scalar_accessor& operator^=(T x) noexcept { + Scalar_accessor& operator^=(U x) noexcept { data[idx] ^= x; return *this; }