From 7d3864be038e7d3bb4b9b266a679f04bdd27560e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 12 Jul 2002 14:32:20 +0000 Subject: [PATCH] tru64cxx6.5 fixes [SVN r14421] --- include/boost/cast.hpp | 60 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp index 695b8bf..1a5b9dc 100644 --- a/include/boost/cast.hpp +++ b/include/boost/cast.hpp @@ -133,7 +133,7 @@ namespace boost template struct limits : std::numeric_limits { - static inline T min() + static inline T min() # ifndef __GNUC__ // bug workaround courtesy Jens Maurer { return std::numeric_limits::min() >= 0 @@ -142,7 +142,7 @@ namespace boost : std::numeric_limits::min(); } # else - ; + ; # endif }; }; @@ -166,13 +166,63 @@ namespace boost }; // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits + template + struct fixed_numeric_limits_base : public numeric_min_select< std::numeric_limits::is_signed >::template limits + {}; + + template + struct fixed_numeric_limits + : fixed_numeric_limits_base::is_specialized)> + {}; + +# ifdef BOOST_HAS_LONG_LONG + // cover implementations which supply no specialization for long + // long / unsigned long long. Not intended to be full + // numeric_limits replacements, but good enough for numeric_cast<> + template <> + struct fixed_numeric_limits_base { + BOOST_STATIC_CONSTANT(bool, is_specialized = true); + BOOST_STATIC_CONSTANT(bool, is_signed = true); + static long long max() + { +# ifdef LONGLONG_MAX + return LONGLONG_MAX; +# else + return 9223372036854775807LL; // hope this is portable +# endif + } + + static long long min() + { +# ifdef LONGLONG_MIN + return LONGLONG_MIN; +# else + return -9223372036854775808LL; // hope this is portable +# endif + } }; + + template <> + struct fixed_numeric_limits_base + { + BOOST_STATIC_CONSTANT(bool, is_specialized = true); + BOOST_STATIC_CONSTANT(bool, is_signed = false); + static unsigned long long max() + { +# ifdef ULONGLONG_MAX + return ULONGLONG_MAX; +# else + return 0xffffffffffffffffULL; // hope this is portable +# endif + } + + static unsigned long long min() { return 0; } + }; +# endif } // namespace detail // less_than_type_min - @@ -310,7 +360,7 @@ namespace boost inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET) { // typedefs abbreviating respective trait classes - typedef std::numeric_limits arg_traits; + typedef detail::fixed_numeric_limits arg_traits; typedef detail::fixed_numeric_limits result_traits; #if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_SGI_CPP_LIMITS)