Boost logo

Boost :

Subject: Re: [boost] [assert] static_assert envy
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2011-01-18 12:57:34


Robert Kawulak wrote:
> Sent: Tuesday, January 18, 2011 6:48 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] [assert] static_assert envy
>
> 2011/1/18 Steven Watanabe <watanabesj_at_[hidden]>:
> > What exactly is wrong with
> > BOOST_ASSERT( !foo() || assertion )
> > or
> > BOOST_ASSERT( foo() ? assertion : true )
> >
> > IMHO, the last thing we need is lots of
> > minor variations that don't add any
> > real utility.
>
> The utility here is communicativeness. Upon seeing:
>
> BOOST_ASSERT( !"we shouldn't get there" );
> BOOST_ASSERT( condition && "this shouldn't happen" );
> BOOST_ASSERT( !foo() || condition && "something is wrong" );
>
> you have to turn your mind into a Karnaugh table for a while if you
> want to understand what this code does. OTOH:

I think there was already agreement that BOOST_ASSERT_MSG is a good thing.

> BOOST_FAIL_MSG( "we shouldn't get there" );

I would prefer
BOOST_ASSERT_MSG( false, "we shouldn't get there" );
so I don't need to think about the details of the differences between BOOST_FAIL_MSG and BOOST_ASSERT.

> BOOST_ASSERT_MSG( condition, "this shouldn't happen" );

+1

> BOOST_ASSERT_IF_MSG( foo(), condition, "something is wrong" );

I would prefer
BOOST_ASSERT_MSG( !foo() || condition, "something is wrong" );
so I don't need to think about the details of the differences between BOOST_ASSERT_IF_MSG and BOOST_ASSERT.

Regards,
Thomas


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