From aedea349aabb44d51a4e64cd2c96242f0cea95ba Mon Sep 17 00:00:00 2001 From: Ville Kallioniemi Date: Mon, 1 Feb 2016 20:25:02 -0700 Subject: Replace separate low word constructors with a single templated constructor. --- unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h b/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h index 0d34f7ee6..981515f4b 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h @@ -33,24 +33,19 @@ struct TensorUInt128 HIGH high; LOW low; + template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE - TensorUInt128(int32_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); + TensorUInt128(const TensorUInt128& 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 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) { + explicit TensorUInt128(const 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) { } -- cgit v1.2.3