> From: Eric Woodruff [mailto:Eric.Woodruff@falsetto.com]
> In my opinion, assertions indicate enfrorcement of pre/post conditions, that
> are separate from the algorithmic logic of a function. What happens from the
> result of the assertion, an exception or an abort is a separate issue.
> Consider (if assert takes a boost::function0<void>):
> assert (!harddrive.isFragmented (), boost::bind (&HardDrive::defrag,
> In this case, it there is a simple remedy to the failed pre-condition. The
> alternative is: assert (!harddrive.isFragmented (), std::abort);
In the first case you're not talking about a failed precondition, because
the logic (of which the assert is a part) is designed to handle both cases.
I don't like the idea of using assert in that way at all and would strongly
encourage it be replaced with:
if (!harddrive.isFragmented()) harddrive.defrag();
I really agree with Peter here, assert shouldn't have a canned option for
throwing. When you really need logic errors to throw you have to put a
non-trivial supporting infrastructure in place and very likely a more
complex protocol then a simple throw. I've spent the last year working on
a server with a "can't stop" requirement and the objects it throws
may include information about the subsystem that's been affected and the
scope of the problem.