Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2001-04-12 17:27:26


At 6:44 PM +0300 4/12/01, Peter Dimov wrote:
>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.

If I understand you correctly you're saying that the code should
evaluate a predicate and call a function which will dispatch to some
handler if the predicate is false. And the function call will always
be made, although the handler may be nil.

Would you do the same with post-conditions? With invariants? What if
a check isn't constant time?

   -- Jesse


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