Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-01-02 12:39:40


"Reece Dunn" <msclrhd_at_[hidden]> writes:

> Dan W. wrote:
>
>>Reece Dunn wrote:
>>> Has there been any discussion regarding an invariants library
>>> (advanced assert), or is there one already implemented in boost?
>
>> The compiler I'm using, Digital Mars version 8.38 already supports
>> invariant, pre- and post-conditions. See...
>>http://www.digitalmars.com/ctg/designbycontract.html
>
> cool! But these seem to work via assert which will terminate the
> program upon invariant failure.
>
> With C++ having exception support, surely the exception mechanism is a
> better way to deal with invariants that do not hold?

almost never. See
http://www.boost-consulting.com/boost/more/error_handling.html
Look for "what about programmer errors?"

> This allows the
> client code to react to the failure and report something readible to
> the user, like:
> invariant failure: cannot access a null pointer, in ...

That's almost always useless from a debugging standpoint.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk