Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-09-09 06:54:09

From: <williamkempf_at_[hidden]>
> When debugging you want the trap to occur as close to the error as
> possible, which is what asserts are good at. With an exception the
> debugger will trap several levels down from where the error actually
> occured, possibly even further down than a debugger allows you to
> traverse back up the stack with. Also, many (most?) debuggers allow
> you to step over the assertion, which would allow you to debug your
> exception trapping code. To my mind asserts are for debugging and
> exceptions are for error handling.

The rationale is sound, but the result does not conform to your
specification. The documentation doesn't state anywhere that a method
asserts; it says that the method throws on error.

Besides, most debuggers can trap exceptions at the time they are thrown.
'assert' should be reserved for undefined behavior detection.

Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at, gregod at, cpdaniel at, john at