Boost logo

Boost Users :

Subject: Re: [Boost-users] max value by the number of bits
From: Robert Ramey (ramey_at_[hidden])
Date: 2013-02-05 11:07:58


Christian Henning wrote:
> Hi there,
>
> is there a general template for calculating the max value by the
> number of bits. GIL right now uses the following template:
>
> template <int K>
> struct unsigned_integral_max_value<packed_channel_value<K> >
> : public mpl::integral_c<typename
> packed_channel_value<K>::integer_t, (1<<K)-1> {};
>
> This code gives me some compiler errors with clang 3.2. for K = 31,
> for instance. Ideally I would like to take K up to 64.
>
> A small fix gets me up to K = 63
>
> template <int K>
> struct unsigned_integral_max_value<packed_channel_value<K> >
> : public mpl::integral_c<typename
> packed_channel_value<K>::integer_t, (uint64_t(1)<<K)-1> {};
>
>
> Is there a better way in boost?

boost::int_max_value_t<V>

http://www.boost.org/doc/libs/1_53_0/libs/integer/doc/html/boost_integer/integer.html

>
> Thanks,
> Christian


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