From cb5b83ef533ed4d734ab2e9389e8c8fc697dda34 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 11 Jul 2002 20:29:50 +0000 Subject: [PATCH] Handle unsigned __int64 for MSVC6 [SVN r14408] --- include/boost/cast.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp index fcbad0d..695b8bf 100644 --- a/include/boost/cast.hpp +++ b/include/boost/cast.hpp @@ -236,6 +236,24 @@ namespace boost template static inline bool check(X x, Y) { return x >= 0 && static_cast(static_cast(x)) != x; } + +# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 + // MSVC6 can't static_cast unsigned __int64 -> floating types +# define BOOST_UINT64_CAST(src_type) \ + static inline bool check(src_type x, unsigned __int64) \ + { \ + if (x < 0) return false; \ + unsigned __int64 y = static_cast(x); \ + bool odd = y & 0x1; \ + __int64 div2 = static_cast<__int64>(y >> 1); \ + return ((static_cast(div2) * 2.0) + odd) != x; \ + } + + BOOST_UINT64_CAST(long double); + BOOST_UINT64_CAST(double); + BOOST_UINT64_CAST(float); +# undef BOOST_UINT64_CAST +# endif }; template<>