Boost logo

Boost :

Subject: Re: [boost] [contract] oldof failure not in N1962?
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-07-19 10:48:30

on Mon Jul 18 2011, Vicente Botet <> wrote:

> Hi Lorenzo,
> I don't remember what N1962 says, but I would force that preconditions and
> post conditions evaluation shall not throw. If an exception is throw during
> precondition evaluation, post-condition preparation or evaluation I would
> say the program should terminate, as the program can not state if the
> conditions are satisfied or not.

That doesn't make any sense to me. If you run out of memory while
evaluating a precondition, it means you can't evaluate the precondition,
not that the program can't recover.

My guidelines are:

- Use exceptions for recoverable conditions.

- Do not use exceptions for non-recoverable conditions

- Failure to satisfy a precondition is a program bug

- Program bugs are non-recoverable

- Anticipated failure to satisfy a postcondition (e.g. I can't get
  enough memory to do my job) is a recoverable condition

- An actual postcondition violations is a program bug.


Dave Abrahams
BoostPro Computing

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