Re: [Boost-users] BOOST_ASSERT and others
From: Sebastian Redl
Maarten Nieber wrote:
Sorry, I should have checked! It should be:
assert( 2 + 2 == 4 && "Adding numbers failed!" )
That still won't fire. The concept is flawed. You cannot use assert()s to print debug messages, because when an assert() prints a message, it also stops the program.
Why won't it fire? Let's say I normally would do this: assert( statement ); If I do this instead: assert( statement && "Statement that 2 + 2 == 4 failed" ); then if "statement" is false, the argument of assert() is false so it fires, and (more importantly), the whole argument, including the diagnostic "Statement that 2 + 2 == 4 failed" is output. Am I missing something? This seems like a clever idea to me (a bit limited, maybe, but useful for prototyping if nothing else). - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837
participants (1)
-
james.jonesīŧ firstinvestors.com