Unary operators were too restrictive in the type of their argument. (#1683)

[ROCm/clr commit: 306d50291e]
Dieser Commit ist enthalten in:
Alex Voicu
2019-11-22 02:24:53 +00:00
committet von Maneesh Gupta
Ursprung 84953da127
Commit 82b55e6502
@@ -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<U, T>{}>::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<U, T>{}>::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<U, T>{}>::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<U, T>{}>::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<std::is_integral<U>{}>::type* = nullptr>
typename std::enable_if<std::is_convertible<U, T>{} &&
std::is_integral<U>{}>::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<std::is_integral<U>{}>::type* = nullptr>
typename std::enable_if<std::is_convertible<U, T>{} &&
std::is_integral<U>{}>::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<std::is_integral<U>{}>::type* = nullptr>
typename std::enable_if<std::is_convertible<U, T>{} &&
std::is_integral<U>{}>::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<std::is_integral<U>{}>::type* = nullptr>
typename std::enable_if<std::is_convertible<U, T>{} &&
std::is_integral<U>{}>::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<std::is_integral<U>{}>::type* = nullptr>
typename std::enable_if<std::is_convertible<U, T>{} &&
std::is_integral<U>{}>::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<std::is_integral<U>{}>::type* = nullptr>
typename std::enable_if<std::is_convertible<U, T>{} &&
std::is_integral<U>{}>::type* = nullptr>
__host__ __device__
Scalar_accessor& operator^=(T x) noexcept {
Scalar_accessor& operator^=(U x) noexcept {
data[idx] ^= x;
return *this;
}