Replace separate low word constructors with a single templated constructor.

This commit is contained in:
Ville Kallioniemi
2016-02-01 20:25:02 -07:00
parent f0fdefa96f
commit aedea349aa
2 changed files with 11 additions and 16 deletions

View File

@@ -33,24 +33,19 @@ struct TensorUInt128
HIGH high;
LOW low;
template<typename OTHER_HIGH, typename OTHER_LOW>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(int32_t x) : high(0), low(x) {
TensorUInt128(const TensorUInt128<OTHER_HIGH, OTHER_LOW>& other) : high(other.high), low(other.low) {
static_assert(sizeof(OTHER_HIGH) <= sizeof(HIGH), "high too wide");
static_assert(sizeof(OTHER_LOW) <= sizeof(LOW), "low too wide");
}
template<typename T>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
explicit TensorUInt128(const T& x) : high(0), low(x) {
eigen_assert(x >= 0);
}
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(uint32_t x) : high(0), low(x) { }
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(long x) : high(0), low(x) {
eigen_assert(x >= 0);
}
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(unsigned long x) : high(0), low(x) { }
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(int64_t x) : high(0), low(x) {
eigen_assert(x >= 0);
}
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(uint64_t x) : high(0), low(x) { }
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
TensorUInt128(uint64_t y, uint64_t x) : high(y), low(x) { }