[Boost-bugs] [Boost C++ Libraries] #3342: vector_c should use maximum integral constant type

Subject: [Boost-bugs] [Boost C++ Libraries] #3342: vector_c should use maximum integral constant type
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-08-14 06:21:21


#3342: vector_c should use maximum integral constant type
------------------------------------------------------+---------------------
 Reporter: Maxim Yanchenko <Maxim.Yanchenko@…> | Owner: agurtovoy
     Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: mpl
  Version: Boost 1.39.0 | Severity: Problem
 Keywords: |
------------------------------------------------------+---------------------
 It looks like currently long is built in, which leads to problems on 32
 bit architectures with sizeofs int = long < int64_t.

 How it's defined currently:
 {{{
 #!cpp
 template<
       typename T, long C0 = LONG_MAX, long C1 = LONG_MAX, long C2 =
 LONG_MAX, ...
>
 struct vector_c;
 }}}


 I believe the maximum integral type (e.g. int64_t) should be used instead
 of long.

 Example that shows the problem:
 {{{
 #!cpp
   const int64_t max_int = integer_traits<int>::const_max;
   const int64_t max_int_plus_1 = max_int + 1;

   BOOST_MPL_ASSERT(( equal< vector_c< int64_t, 1 >
                           , vector< integral_c< int64_t, 1 > >
> ));

   BOOST_MPL_ASSERT(( equal< vector_c< int64_t, max_int >
                           , vector< integral_c< int64_t, max_int > >
> ));

   BOOST_MPL_ASSERT(( equal< vector_c< int64_t, max_int_plus_1 >
                           , vector< integral_c< int64_t, max_int_plus_1 >
>
> ));
 }}}
 The first assert passes, while the second and third fail with the
 following
 error messages (removed repetition of 2147483647l for readability):
 {{{
 test.h:149: error: ************mpl::equal<mpl::vector_c<int64_t,
 2147483647l,
 2147483647l, ...>, mpl::vector<mpl_::integral_c<int64_t, 2147483647>>,
 is_same<true> >::************'
 test.h:153: error: ************mpl::equal<mpl::vector_c<int64_t,
 -0x00000000080000000l, 2147483647l, ...>,
 mpl::vector<mpl_::integral_c<int64_t,
 2147483648ll>>, is_same<true> >::************'
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3342>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC