Boost logo

Boost Users :

Subject: Re: [Boost-users] max value by the number of bits
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2013-02-05 20:24:19


On Tue, Feb 5, 2013 at 4:56 PM, Robert Ramey <ramey_at_[hidden]> wrote:

> Christian Henning wrote:
> >> boost::int_max_value_t<V>
> >>
> >>
> http://www.boost.org/doc/libs/1_53_0/libs/integer/doc/html/boost_integer/integer.html
> >>
> >
> > Robert, are you sure I can get the max value of a 15bit value using
> > int_max_value_t?
>
> whoops - I totally misread your question, I was thinking you wanted the
> TYPE
> which
> would hold a max value corresponding to 15 bits.
>
> It turns out that I've been working in this area recently. I would suggest
> skipping
> the mpl layer and using BOOST_STATIC_CONSTANT directly. The reason
> is that mpl includes some operations like next which might not work for
> 2^64
> etc.
>
> template <int K>
> struct unsigned_integral_max_value struct {
> BOOST_STATIC_CONSTANT( boost::uintmax_t, value = ((boost::uintmax_t)1
> <<
> K)-1);
> };
>

Isn't this pretty much exactly what Christian was using before? If so, I'd
guess it still has the same compile-time-overflow issues. But maybe I'm
misremembering the original problem :/

- Jeff



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net