Boost logo

Boost :

From: joaquin_at_[hidden]
Date: 2008-07-09 05:24:30


Daryle Walker escribió:
> On Jul 9, 2008, at 3:02 AM, joaquin_at_[hidden] wrote:
>
[...]
>> You can use boost::mpl::equal to test this:
>>
>> BOOST_STATIC_ASSERT
>> ( (boost::mpl::equal<distinct_integral_bit_counts,
>> boost::mpl::list_c<int, 8, 16, 32> >::value) );
>> }
>>
>> Other than that, your type_to_digit_count is perfectly lambda-
>> cabable AFAICS. HTH,
>>
>
> Thanks. I switched to mpl::equal and it compiled. I later switched
> to BOOST_MPL_ASSERT. (Remember to take _out_ the "::value" part!) I
> originally had the "integral_c" part of "type_to_digit_count" as a
> member called "type," instead of as a base class, then I switched
> back and forth. Both ways work. Why is that?

Because integral_c (and all other integral constant types in Boost.MPL)
evaluates to itself,
that is, it has the form:

  template<typename T, T N>struct integral_c
  {
    typedef integral_c<T,N> type;
    ...
  };

> And which way is best
> (if they're not equally good, and without a better third alternative)?
>

I don't think it makes any difference in compile times or otherwise, but
deriving
from integral_c is terser and more MPL-idiomatic.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk