Boost logo

Boost :

Subject: Re: [boost] [assert] static_assert envy
From: Beman Dawes (bdawes_at_[hidden])
Date: 2011-01-17 12:37:37


On Mon, Jan 17, 2011 at 10:42 AM, Eric Niebler <eric_at_[hidden]> wrote:

> On 1/17/2011 10:24 PM, Robert Kawulak wrote:
> >> From: Beman Dawes
> >> BOOST_EXTENDED_ASSERT(true, "This will not assert");
> >> BOOST_EXTENDED_ASSERT(false, "This will assert");
> >
> > +1, although I hate the name - it's too long. The use of asserts should
> be encouraged by making them fast to type and cluttering the
> > code as little as possible. Right now I can't think of any obviously good
> name, but maybe BOOST_ASSERTM (assert with message)?
>
> It should be BOOST_ASSERT_MSG, just as MPL has BOOST_MPL_ASSERT_MSG.

Ha! Much better! Thanks!

> And
> +1 to Dean's suggestion of std::abort.

Yeah, that's better if I can only figure out how to stop the [expletive
deleted] Windows dialog boxes.

> And also, can we find a better
> option than writing to std::cerr?

I really don't like std::cerr either, because it doesn't interleave
correctly with cout on VC++ builds.

What about changing to std::cout as the default of all of
<boost/assert.hpp>, but with a configuration macro available to override the
default?

> And lastly, just as with BOOST_ASSERT,
> there should be a way to hook it to install your own failed-assertion
> handler.

Yeah, I assumed that, but didn't want to bother with it unless the basic
idea of BOOST_ASSERT_MSG() flies.

> That is all. :-)
>
> Much help,

Thanks,

--Beman


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