From ab9463baf120e6925a90031f2d619faf0b52a6af Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Tue, 4 Feb 2003 20:21:36 +0000 Subject: [PATCH] ICE cast fixes [SVN r17209] --- include/boost/mpl/aux_/ice_cast.hpp | 12 ++++++------ include/boost/mpl/if.hpp | 5 +++++ include/boost/mpl/integral_c.hpp | 19 ++++++++----------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/boost/mpl/aux_/ice_cast.hpp b/include/boost/mpl/aux_/ice_cast.hpp index 0659fc0..ffa6226 100644 --- a/include/boost/mpl/aux_/ice_cast.hpp +++ b/include/boost/mpl/aux_/ice_cast.hpp @@ -3,7 +3,7 @@ // See http://www.boost.org for updates, documentation, and revision history. //----------------------------------------------------------------------------- // -// Copyright (c) 2001-02 +// Copyright (c) 2001-03 // Aleksey Gurtovoy // // Permission to use, copy, modify, distribute and sell this software @@ -17,12 +17,12 @@ #ifndef BOOST_MPL_AUX_ICE_CAST_HPP_INCLUDED #define BOOST_MPL_AUX_ICE_CAST_HPP_INCLUDED -#include "boost/config.hpp" +#include "boost/mpl/aux_/config/workaround.hpp" -#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x561 || !defined(BOOST_STRICT_CONFIG)) \ - || defined(__GNUC__) && __GNUC__ < 3 -# define BOOST_MPL_AUX_ICE_CAST(T, expr) expr -#elif defined(__MWERKS__) && __MWERKS__ <= 0x3001 +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) \ + || BOOST_WORKAROUND(__GNUC__, < 3) +# define BOOST_MPL_AUX_ICE_CAST(T, expr) T(expr) +#elif BOOST_WORKAROUND(__MWERKS__, <= 0x3001) # define BOOST_MPL_AUX_ICE_CAST(T, expr) (T)(expr) #else # define BOOST_MPL_AUX_ICE_CAST(T, expr) static_cast(expr) diff --git a/include/boost/mpl/if.hpp b/include/boost/mpl/if.hpp index a1788ee..55f4f46 100644 --- a/include/boost/mpl/if.hpp +++ b/include/boost/mpl/if.hpp @@ -20,6 +20,7 @@ #include "boost/mpl/aux_/ice_cast.hpp" #include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/lambda_support.hpp" +#include "boost/mpl/aux_/config/workaround.hpp" #include "boost/config.hpp" namespace boost { @@ -56,7 +57,11 @@ struct if_ private: // agurt, 02/jan/03: two-step 'type' definition for the sake of aCC typedef if_c< +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) + BOOST_MPL_AUX_VALUE_WKND(C)::value +#else BOOST_MPL_AUX_ICE_CAST(bool, BOOST_MPL_AUX_VALUE_WKND(C)::value) +#endif , T1 , T2 > almost_type_; diff --git a/include/boost/mpl/integral_c.hpp b/include/boost/mpl/integral_c.hpp index daa99e6..c00d8a7 100644 --- a/include/boost/mpl/integral_c.hpp +++ b/include/boost/mpl/integral_c.hpp @@ -17,6 +17,7 @@ #ifndef BOOST_MPL_INTEGRAL_C_HPP_INCLUDED #define BOOST_MPL_INTEGRAL_C_HPP_INCLUDED +#include "boost/mpl/aux_/ice_cast.hpp" #include "boost/mpl/aux_/config/static_constant.hpp" #include "boost/mpl/aux_/config/workaround.hpp" @@ -45,23 +46,19 @@ struct integral_c // either #if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243 private: - BOOST_STATIC_CONSTANT(T, next_value = static_cast(N + 1)); - BOOST_STATIC_CONSTANT(T, prior_value = static_cast(N - 1)); + BOOST_STATIC_CONSTANT(T, next_value = BOOST_MPL_AUX_ICE_CAST(T, (N + 1))); + BOOST_STATIC_CONSTANT(T, prior_value = BOOST_MPL_AUX_ICE_CAST(T, (N - 1))); public: typedef integral_c next; typedef integral_c prior; #elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) \ + || BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(502)) \ || BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(53800)) - // Borland can't handle the casts, and HP doesn't need them - // because the 2nd template parameter is not T but long - typedef integral_c next; - typedef integral_c prior; -#elif BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(502)) - typedef integral_c(N + 1)> next; - typedef integral_c(N - 1)> prior; + typedef integral_c next; + typedef integral_c prior; #else - typedef integral_c(value + 1)> next; - typedef integral_c(value - 1)> prior; + typedef integral_c next; + typedef integral_c prior; #endif // enables uniform function call syntax for families of overloaded