Boost logo

Boost :

Subject: Re: [boost] [assert] static_assert envy
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2011-01-18 06:58:45


Den 17-01-2011 16:06, Beman Dawes skrev:
> 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;
> }
>

I'm fine with BOOST_ASSERT_MSG(). Since we are adding assert.hpp I would
like to see

   BOOST_ASSERT_IF()
   BOOST_ASSERT_IF_MSG()

as well. It is really much clearer to read and maintain than

   BOOST_ASSERT( !foo() || condition );

-Thorsten


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