Subject: Re: [boost] BOOST_ASSERT_IF() [again]
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-05-06 04:16:51
Scott McMurray skrev:
> On Tue, May 5, 2009 at 20:11, Richard Holden <aciddeath_at_[hidden]> wrote:
>> Could you provide an usage example please, I understand the macro but I
>> don't understand the usage pattern.
> Perhaps something like this?
> BOOST_ASSERT_IF( !c.empty(), *c.begin() < *c.rbegin() );
> Perhaps it would be better named BOOST_ASSERT_IMPLIES?
It's an implication allright, but also an "if" :-) :
if( IF )
BOOST_ASSERT( X );
The usage is whenever you want to make an assertion conditional on
something. It happens quite frequent.
And you cannot write the if statement above if you want to be sure
the whole thing is optimized away, therefore the new macro.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk