
Robert Kawulak wrote:
Sent: Tuesday, January 18, 2011 6:48 PM To: boost@lists.boost.org Subject: Re: [boost] [assert] static_assert envy
2011/1/18 Steven Watanabe <watanabesj@gmail.com>:
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