diff options
author | 2016-02-02 20:58:06 -0800 | |
---|---|---|
committer | 2016-02-02 20:58:06 -0800 | |
commit | dc413dbe8a05b6dd064471788dc469ddc8e4d2a2 (patch) | |
tree | 1caa16d42df78b7dc7c2055e69c7f4dbe9b1f654 /unsupported | |
parent | 99cde88341145c43fc4134af07556d8c6ff12066 (diff) | |
parent | 783018d8f65faeec0fc6f795bc2630240ecdd051 (diff) |
Merged in ville-k/eigen/explicit_long_constructors (pull request PR-158)
Add constructor for long types.
Diffstat (limited to 'unsupported')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h | 15 | ||||
-rw-r--r-- | unsupported/test/cxx11_tensor_uint128.cpp | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h b/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h index f43f64cde..52d5b7b1a 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h @@ -33,18 +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) { - eigen_assert(x >= 0); + TensorUInt128(const TensorUInt128<OTHER_HIGH, OTHER_LOW>& other) : high(other.high), low(other.low) { + EIGEN_STATIC_ASSERT(sizeof(OTHER_HIGH) <= sizeof(HIGH), "high too wide"); + EIGEN_STATIC_ASSERT(sizeof(OTHER_LOW) <= sizeof(LOW), "low too wide"); } + + template<typename T> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE - TensorUInt128(uint32_t 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) { } diff --git a/unsupported/test/cxx11_tensor_uint128.cpp b/unsupported/test/cxx11_tensor_uint128.cpp index ee3767e58..424c70197 100644 --- a/unsupported/test/cxx11_tensor_uint128.cpp +++ b/unsupported/test/cxx11_tensor_uint128.cpp @@ -127,7 +127,7 @@ void test_misc2() { TensorUInt128<uint64_t, uint64_t> result = (TensorUInt128<uint64_t, static_val<0> >(shift, 0) / TensorUInt128<static_val<0>, uint64_t>(divider) - TensorUInt128<static_val<1>, static_val<0> >(1, 0) + TensorUInt128<static_val<0>, static_val<1> >(1)); uint64_t actual = static_cast<uint64_t>(result); - VERIFY_EQUAL(actual, expected); + VERIFY_IS_EQUAL(actual, expected); } } } |