BOOST_ASSERT_IF() [again]

Hi Everyone, Does anyone oppose that I add this macro to supplement BOOST_ASSERT()? It's defined simply as #define BOOST_ASSERT_IF(IF,X) BOOST_ASSERT( (!(IF)) || (X) ) I think it renders assertions somewhat easier to read. -Thorsten

Thorsten Ottosen wrote:
Hi Everyone,
Does anyone oppose that I add this macro to supplement BOOST_ASSERT()? It's defined simply as
#define BOOST_ASSERT_IF(IF,X) BOOST_ASSERT( (!(IF)) || (X) )
I think it renders assertions somewhat easier to read.
-Thorsten _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Could you provide an usage example please, I understand the macro but I don't understand the usage pattern. -Richard Holden Quest Software

On Tue, May 5, 2009 at 20:11, Richard Holden <aciddeath@gmail.com> wrote:
Could you provide an usage example please, I understand the macro but I don't understand the usage pattern.
Perhaps something like this? BOOST_ASSERT_IF( !c.empty(), *c.begin() < *c.rbegin() ); Perhaps it would be better named BOOST_ASSERT_IMPLIES? ~ Scott

Scott McMurray skrev:
On Tue, May 5, 2009 at 20:11, Richard Holden <aciddeath@gmail.com> wrote:
Could you provide an usage example please, I understand the macro but I don't understand the usage pattern.
Perhaps something like this?
BOOST_ASSERT_IF( !c.empty(), *c.begin() < *c.rbegin() );
Perhaps it would be better named BOOST_ASSERT_IMPLIES?
It's an implication allright, but also an "if" :-) : if( IF ) BOOST_ASSERT( X ); The usage is whenever you want to make an assertion conditional on something. It happens quite frequent. And you cannot write the if statement above if you want to be sure the whole thing is optimized away, therefore the new macro. -Thorsten
participants (3)
-
Richard Holden
-
Scott McMurray
-
Thorsten Ottosen