Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-11-13 10:40:16

From: "Kevin S. Van Horn" <kevin.vanhorn_at_[hidden]>
> On Mon, 12 Nov 2001, Peter Dimov wrote:
> > Strictly speaking "an exception is thrown when a precondition is not
met" is
> > an oxymoron. Not meeting a precondition invokes undefined behavior.
> No, it's not an oxymoron; it just can't be guaranteed behavior.

True, that's why from a 'pedantic' point of view the results of not meeting
a precondition are undefined. Nothing is guaranteed in the general case, so
portable code cannot rely on an exception being thrown (or on any other
behavior) and will _never_ invoke a function without meeting the

Bugs - in library code or in user code - aren't documented.

> You'll
> notice from my other comments that I am generally wary of specifying that
> an exception *will* be thrown when a logical (programmer) error occurs.


However my point is that documenting that an exception X _will_ be thrown
when condition Y is not met means that Y is _not_ a precondition. Invoking
the function with Y not met is _not_ a programming error. It's relying on
documented behavior.

Sometimes this is a valid alternative.

Peter Dimov
Multi Media Ltd.

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