Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-04-12 10:44:34


From: "David Abrahams" <abrahams_at_[hidden]>

> Oof. I am still reluctant to add throwing behavior for precondition
checks,
> though people seem to want it.

Rightly so, since by definition, if a function is documented to throw if X,
then X is not a precondition.

The user should probably be able to make precondition_violation throw by
overriding it (set_precondition_handler?), but throwing shouldn't be one of
the 'standard' behaviors of precondition_violation.

The options for the documented interface of a function, as I see them, are:

[1] f() throws if X;
[2] f() calls precondition_violation if X;
[3] the behavior of f() is undefined if X.

Having precondition_violation won't make the question of choosing among the
three magically go away, however. :-)

Note that I think that [2] should work the same in debug or release builds,
with the possible exception that the default handler may do different
things. The check should not disappear.

--
Peter Dimov
Multi Media Ltd.

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