Michiel Helvensteijn wrote:
I've changed BOOST_ASSERT for my personal use:
#define BOOST_ASSERT(expr) { \ if (!(expr)) { \ ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, \ __FILE__, __LINE__); \ abort(); \ } \ }
there may have been a reason to push everything into the ternary operator that I am not aware of.
In general, I think the major issue with changing macro contents from a simple statement to a compound statement is that it can have peculiar effects on code surrounding macro invocations. For instance (contrived example): if (! data.valid()) BOOST_ASSERT(false); else { // ...process 'data'... } The classic workaround is to wrap the compound statement in a no-op 'do' statement: #define MACRO(stuff) do /* intended macro contents */ while (0) If there are special constraints unique to BOOST_ASSERT, I don't know them.