diff options
author | Alexey Frunze <afrunze@wavecomp.com> | 2018-08-08 20:19:32 -0700 |
---|---|---|
committer | Alexey Frunze <afrunze@wavecomp.com> | 2018-08-08 20:19:32 -0700 |
commit | 050bcf61261d5b3bcc86b2c5afc7e35d3fd16ff7 (patch) | |
tree | 78464d9ae8319f30eced8776b191be9f80da7ca7 /Eigen/src/Core/util/Meta.h | |
parent | 57472886764ff71ad45338c6538649f7a8fa3d0e (diff) |
bug #1584: Improve random (avoid undefined behavior).
Diffstat (limited to 'Eigen/src/Core/util/Meta.h')
-rwxr-xr-x | Eigen/src/Core/util/Meta.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index f27b8e85d..1e4f95581 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -128,6 +128,27 @@ template<> struct is_integral<unsigned __int64> { enum { value = true }; } #endif #endif +#if EIGEN_HAS_CXX11 +using std::make_unsigned; +#else +// TODO: Possibly improve this implementation of make_unsigned. +// It is currently used only by +// template<typename Scalar> struct random_default_impl<Scalar, false, true>. +template<typename> struct make_unsigned; +template<> struct make_unsigned<char> { typedef unsigned char type; }; +template<> struct make_unsigned<signed char> { typedef unsigned char type; }; +template<> struct make_unsigned<unsigned char> { typedef unsigned char type; }; +template<> struct make_unsigned<signed short> { typedef unsigned short type; }; +template<> struct make_unsigned<unsigned short> { typedef unsigned short type; }; +template<> struct make_unsigned<signed int> { typedef unsigned int type; }; +template<> struct make_unsigned<unsigned int> { typedef unsigned int type; }; +template<> struct make_unsigned<signed long> { typedef unsigned long type; }; +template<> struct make_unsigned<unsigned long> { typedef unsigned long type; }; +#if EIGEN_COMP_MSVC +template<> struct make_unsigned<signed __int64> { typedef unsigned __int64 type; }; +template<> struct make_unsigned<unsigned __int64> { typedef unsigned __int64 type; }; +#endif +#endif template <typename T> struct add_const { typedef const T type; }; template <typename T> struct add_const<T&> { typedef T& type; }; |