Boost logo

Boost :

Subject: Re: [boost] Is there interest in unit testing both passing and failing BOOST_MPL_ASSERTs?
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-09-15 12:17:01


on Wed Sep 14 2011, Ben Robinson <icaretaker-AT-gmail.com> wrote:

>>
>
>> Okay, let me see if I understand now: You want a way for the compiler to
>> ignore the static assertions and actually *try* to compile to errant code
>> to
>> ensure that you do, in fact, get a compiler error (which would normally be
>> caught early on by the static assertion). Is that right?
>>
>> - Jeff
>>
>> Yes. That is exactly it. :)
>
> One simple practical example I can give, is that in a library of mine, I
> have overloaded the free function operator+ for certain types of arguments.
> I then include the following in the function body:following:
>
> BOOST_MPL_ASSERT(sizof(T) == 0);

No you don't :-)

That shouldn't compile under any circumstances. BOOST_MPL_ASSERT takes
a parenthesized type, not an integral constant expression, as an
argument.

  BOOST_MPL_ASSERT((mpl::equal_to<int_<sizeof(T)>, int_<0> >))

might work.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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