Boost logo

Boost Users :

From: james.jones_at_[hidden]
Date: 2006-12-18 10:23:21


From: Sebastian Redl <sebastian.redl_at_[hidden]>
> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net