From 906d09b51193bd8355bd56f1508711ad11213cb9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 18 Oct 2000 13:52:09 +0000 Subject: [PATCH] a fix for "unsigned type always passes this test" warnings under GCC. [SVN r7999] --- include/boost/cast.hpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp index 5e3009e..2283bb1 100644 --- a/include/boost/cast.hpp +++ b/include/boost/cast.hpp @@ -166,26 +166,44 @@ namespace boost // between signed and unsigned values. // // "poor man's partial specialization" is in use here. - template + template struct greater_than_type_max; template<> - struct greater_than_type_max + struct greater_than_type_max { template - static bool check(X x, Y y_max) + static inline bool check(X x, Y y_max) { return x > y_max; } }; template <> - struct greater_than_type_max + struct greater_than_type_max { // What does the standard say about this? I think it's right, and it // will work with every compiler I know of. template - static bool check(X x, Y) + static inline bool check(X x, Y) { return x >= 0 && static_cast(static_cast(x)) != x; } }; + + template<> + struct greater_than_type_max + { + template + static inline bool check(X x, Y y_max) + { return x > y_max; } + }; + + template <> + struct greater_than_type_max + { + // What does the standard say about this? I think it's right, and it + // will work with every compiler I know of. + template + static inline bool check(X x, Y) + { return static_cast(static_cast(x)) != x; } + }; #endif template @@ -207,7 +225,7 @@ namespace boost const bool same_sign = arg_is_signed == result_is_signed; if (less_than_type_min::check(arg, result_traits::min()) - || greater_than_type_max::check(arg, result_traits::max()) + || greater_than_type_max::check(arg, result_traits::max()) ) #else // We need to use #pragma hacks if available