From 82f1cf3786629995604ea6042747dfc3260fe734 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 31 Jan 2003 19:39:56 +0000 Subject: [PATCH] Handle enum types. ** Aleksey, I have some doubts about whether this will cause problems on the various compilers we work on. I also wonder whether it implies that our arithmetic ops all need to be changed.** [SVN r17132] --- include/boost/mpl/integral_c.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/boost/mpl/integral_c.hpp b/include/boost/mpl/integral_c.hpp index f0de576..bd4088f 100644 --- a/include/boost/mpl/integral_c.hpp +++ b/include/boost/mpl/integral_c.hpp @@ -37,24 +37,27 @@ struct integral_c typedef integral_c type; typedef T value_type; + // Note that the static_casts below are there to handle the case + // where T is an enum type. + // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC), // while some other don't like 'value + 1' (Borland), and some don't like // either #if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243 private: - BOOST_STATIC_CONSTANT(T, next_value = (N + 1)); - BOOST_STATIC_CONSTANT(T, prior_value = (N - 1)); + BOOST_STATIC_CONSTANT(T, next_value = static_cast(N + 1)); + BOOST_STATIC_CONSTANT(T, prior_value = static_cast(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)) - typedef integral_c next; - typedef integral_c prior; + typedef integral_c(N + 1)> next; + typedef integral_c(N - 1)> prior; #else - typedef integral_c next; - typedef integral_c prior; + typedef integral_c(value + 1)> next; + typedef integral_c(value - 1)> prior; #endif // enables uniform function call syntax for families of overloaded