Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2002-02-04 15:12:30


Peter's cut at a Boost assert header is in <boost/assert.hpp> in cvs.

My cut at a Boost assert is this:

    #ifdef BOOST_ASSERT_CUSTOMIZATION_HEADER
    #include BOOST_ASSERT_CUSTOMIZATION_HEADER
    #endif

    #ifndef BOOST_ASSERT
    #include <assert.h>
    #define BOOST_ASSERT assert(x)
    #endif

I can provide extensive arguments for why I prefer my cut, but they boil
down to:

    0) simple
    1) default behavior same as assert() from <assert.h>
    2) easy to fit into whatever local assert framework your project uses

Peter's version is a bit more full-featured, and has at least one drawback:

    0) currently off by default, although Peter has expressed willingness to
change that
    1) if you define BOOST_DEBUG to turn on Boost asserts, you then have to
define a boost_error function somewhere in your program

Neither version attempts to categorize asserts in Boost. I suggest we
continue to use asserts for precondition checking. I believe that one of
Peter's arguments in favor of a Boost assert that is off by default is that
it makes it more likely that library authors will add more precondition
asserts.

How can we decide which of these versions of <boost/assert.hpp> should be
part of Boost? I'm not sure the formal review process is suitable for
evaluating competing proposals.

For the pending release, it's fine with me to ship Peter's first cut.

Any and all comments about these two proposals for Boost asserts would be
appreciated, but lets beware Parkinson's Bicycle Shed (see the bottom of
<http://www.boost.org/more/discussion_policy.htm>), because asserts seem to
be a subject that everyone has an opinion about.

    -- Darin


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