Add missing compound assignment operators. (#1216)

[ROCm/clr commit: e701e337f9]
This commit is contained in:
mhbliao
2019-07-11 05:16:15 -04:00
کامیت شده توسط Maneesh Gupta
والد 877fd02244
کامیت e402a1db65
@@ -294,6 +294,7 @@ THE SOFTWARE.
++*this; ++*this;
return tmp; return tmp;
} }
inline __host__ __device__ inline __host__ __device__
HIP_vector_type& operator--() noexcept HIP_vector_type& operator--() noexcept
{ {
@@ -306,12 +307,23 @@ THE SOFTWARE.
--*this; --*this;
return tmp; return tmp;
} }
inline __host__ __device__ inline __host__ __device__
HIP_vector_type& operator+=(const HIP_vector_type& x) noexcept HIP_vector_type& operator+=(const HIP_vector_type& x) noexcept
{ {
data += x.data; data += x.data;
return *this; return *this;
} }
template<
typename U,
typename std::enable_if<
std::is_convertible<U, T>{}>::type* = nullptr>
inline __host__ __device__
HIP_vector_type& operator+=(U x) noexcept
{
return *this += HIP_vector_type{x};
}
inline __host__ __device__ inline __host__ __device__
HIP_vector_type& operator-=(const HIP_vector_type& x) noexcept HIP_vector_type& operator-=(const HIP_vector_type& x) noexcept
{ {
@@ -327,18 +339,38 @@ THE SOFTWARE.
{ {
return *this -= HIP_vector_type{x}; return *this -= HIP_vector_type{x};
} }
inline __host__ __device__ inline __host__ __device__
HIP_vector_type& operator*=(const HIP_vector_type& x) noexcept HIP_vector_type& operator*=(const HIP_vector_type& x) noexcept
{ {
data *= x.data; data *= x.data;
return *this; return *this;
} }
template<
typename U,
typename std::enable_if<
std::is_convertible<U, T>{}>::type* = nullptr>
inline __host__ __device__
HIP_vector_type& operator*=(U x) noexcept
{
return *this *= HIP_vector_type{x};
}
inline __host__ __device__ inline __host__ __device__
HIP_vector_type& operator/=(const HIP_vector_type& x) noexcept HIP_vector_type& operator/=(const HIP_vector_type& x) noexcept
{ {
data /= x.data; data /= x.data;
return *this; return *this;
} }
template<
typename U,
typename std::enable_if<
std::is_convertible<U, T>{}>::type* = nullptr>
inline __host__ __device__
HIP_vector_type& operator/=(U x) noexcept
{
return *this /= HIP_vector_type{x};
}
template< template<
typename U = T, typename U = T,
@@ -361,6 +393,7 @@ THE SOFTWARE.
r.data = ~r.data; r.data = ~r.data;
return r; return r;
} }
template< template<
typename U = T, typename U = T,
typename std::enable_if<std::is_integral<U>{}>::type* = nullptr> typename std::enable_if<std::is_integral<U>{}>::type* = nullptr>
@@ -370,6 +403,7 @@ THE SOFTWARE.
data %= x.data; data %= x.data;
return *this; return *this;
} }
template< template<
typename U = T, typename U = T,
typename std::enable_if<std::is_integral<U>{}>::type* = nullptr> typename std::enable_if<std::is_integral<U>{}>::type* = nullptr>
@@ -379,6 +413,7 @@ THE SOFTWARE.
data ^= x.data; data ^= x.data;
return *this; return *this;
} }
template< template<
typename U = T, typename U = T,
typename std::enable_if<std::is_integral<U>{}>::type* = nullptr> typename std::enable_if<std::is_integral<U>{}>::type* = nullptr>
@@ -388,6 +423,7 @@ THE SOFTWARE.
data |= x.data; data |= x.data;
return *this; return *this;
} }
template< template<
typename U = T, typename U = T,
typename std::enable_if<std::is_integral<U>{}>::type* = nullptr> typename std::enable_if<std::is_integral<U>{}>::type* = nullptr>
@@ -397,6 +433,7 @@ THE SOFTWARE.
data &= x.data; data &= x.data;
return *this; return *this;
} }
template< template<
typename U = T, typename U = T,
typename std::enable_if<std::is_integral<U>{}>::type* = nullptr> typename std::enable_if<std::is_integral<U>{}>::type* = nullptr>
@@ -406,6 +443,7 @@ THE SOFTWARE.
data >>= x.data; data >>= x.data;
return *this; return *this;
} }
template< template<
typename U = T, typename U = T,
typename std::enable_if<std::is_integral<U>{}>::type* = nullptr> typename std::enable_if<std::is_integral<U>{}>::type* = nullptr>