Boost logo

Boost :

Subject: Re: [boost] [assert] Assert library? - Was: [regression] Where'sboost/assert.hpp ??
From: Peter Dimov (lists_at_[hidden])
Date: 2014-02-28 19:43:35


>> [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3877.pdf
>
> Assertion macros taking a level (BOOST_ASSERTL, BOOST_ASSERTL_MSG)
> controlled by, f.ex. BOOST_ASSERT_LEVEL (0 - opt, 1 - debug, 2 - safe)
> would be a relatively straightforward addition.

The N3877 approach of supplying three separate macros, one per level, has
one advantage though - it doesn't generate "condition is always true/false"
warnings.

Assume for instance that BOOST_ASSERTL(expr, level) is

  ((level) <= BOOST_ASSERT_LEVEL? BOOST_ASSERT(expr): (void)0)

Here level <= BOOST_ASSERT_LEVEL will almost always be a constant
expression, hence warnings.


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