[integer] Proposal: minor addition to cstdint.hpp: largest integer types for value-based template arguments

I just added some class templates that had declarations like: //======================================== template < intmax_t Value > struct whatever; //======================================== Afterwards, I was looking over some of the Boost.Integer headers and got curious about the BOOST_NO_INTEGRAL_INT64_T setting used within <boost/integer_traits.hpp>. I think we could add two typedefs to <boost/cstdint.hpp> //======================================== #if !defined(BOOST_NO_INT64_T) && defined(BOOST_NO_INTEGRAL_INT64_T) typedef signed long intmaxc_t; typedef unsigned long uintmaxc_t; #else typedef intmax_t intmaxc_t; typedef uintmax_t uintmaxc_t; #endif //======================================== Where "intmaxc_t" is the largest signed integer type that is suitable for integer constant expressions (like value-based template parameters) and "uintmaxc_t" is the unsigned equivalent. They should be the same as "intmax_t" and "uintmax_t" on non-broken compilers. I'd change my code to use the new types, to be safer. -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com

Added as ticket #2135, <http://svn.boost.org/trac/boost/ticket/2135>, so I/we don't forget. On Jul 17, 2008, at 4:02 AM, Daryle Walker wrote:
I just added some class templates that had declarations like:
//======================================== template < intmax_t Value > struct whatever; //========================================
Afterwards, I was looking over some of the Boost.Integer headers and got curious about the BOOST_NO_INTEGRAL_INT64_T setting used within <boost/integer_traits.hpp>. I think we could add two typedefs to <boost/cstdint.hpp>
//======================================== #if !defined(BOOST_NO_INT64_T) && defined(BOOST_NO_INTEGRAL_INT64_T) typedef signed long intmaxc_t; typedef unsigned long uintmaxc_t; #else typedef intmax_t intmaxc_t; typedef uintmax_t uintmaxc_t; #endif //========================================
Where "intmaxc_t" is the largest signed integer type that is suitable for integer constant expressions (like value-based template parameters) and "uintmaxc_t" is the unsigned equivalent. They should be the same as "intmax_t" and "uintmax_t" on non-broken compilers. I'd change my code to use the new types, to be safer.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
participants (1)
-
Daryle Walker