Boost logo

Boost :

Subject: Re: [boost] [assert] static_assert envy
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-01-17 11:57:22


AMDG

On 1/17/2011 7:06 AM, Beman Dawes wrote:
> Whenever I write a BOOST_ASSERT macro, I'm envious of C++0x static_assert
> because of its ability to supply a clear error message. I'd really like to
> be able to write a variant of BOOST_ASSERT like this:
>
> #include<boost/assert.hpp>
> int main()
> {
> BOOST_EXTENDED_ASSERT(true, "This will not assert");
> BOOST_EXTENDED_ASSERT(false, "This will assert");
> return 0;
> }
>
> And then get debug mode output like this:
>
> ***** Internal Program Error - Assertion Failed *****
> extended_assert_test.cpp(6): error in int main(void): This will assert
>
> Adding the code below at the end of<boost/assert.hpp> will do just that. It
> isn't totally ready for prime time, but it would be nice to find out if
> others would like something similar added to<boost/assert.hpp>.
>

Is there anything wrong with the idiom

assert(true && "This will not assert");

In Christ,
Steven Watanabe


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