Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-05-08 10:40:29


On Thu, 8 May 2003 15:06:02 +0300, "John Torjo" <john_at_[hidden]>
wrote:

>Unfortunately, we can't use the do-while(0) idiom, since we don't know when
>while(0) will be ;-)
>
>Example:
>BOOST_ASSERT(i != j)(i)(j);
>
>or
>
>BOOST_ASSERT(i > 1000)(i);

Oops, no. That's not the problem. The problem is that I read Daniel's
reply out of context and too absent-mindedly :-) I thought it was
something like

  if (false) ; else

whereas he is really testing for a condition

  if(expr)...

However, if you are going to abort at the end (or throw, but I don't
want to enter in this matter) you can simply replace 'if' with
'while':

#define BOOST_INVARIANT(expr) \
    while /*if*/ (!(expr)) \
        boost::invariant(), \
        std::clog << "invariant failure: " #expr, \
        boost::BOOST_INVARIANT_A \
                                                  \
    /**/

But don't care about that. Had I noticed that there was really a
condition I wouldn't have replied. And, then, Borland will find some
way to warn in any case :-)

>note: see the 'smart assert' thread, where we discuss details about the
>interface/ implementation of the smart assert (BOOST_ASSERT)

I have no time. And, from the little I've read, I've noticed quite a
confusion between exceptions and asserts.

Genny.


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