Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-04-17 08:23:20

On 04/17/2005 08:56 AM, Yariv Tal wrote:
> Is there a need for a Design by Contract (a.k.a Pre & Post conditions)
> library?

> Unlike many other such libraries it allows for defining all condition
> types at the begining of the method, instead of making you define the
> "post" checks just before method exit (which usually constrains you
> to a single-point-of-method-exit design).
> See EXAMPLES below.
> Here's a quick summary of condition types:
> - Pre conditions - tested immidiately
> - Post conditions - tested on exiting the method normally (not due to
> an exception). You can use both "pre"(=old) values and "post"
> (=current) values in the test expression (i.e.
> "pre(size) < post(size)").
> If the method returns a value then you can also, with some work on
> your part, test against it (i.e. "retval > 0").
> - Exceptional conditions - tested on exiting the method due to an
> exception. You can use both "pre" and "post" values in the test
> expression.
> - Delayed Assert - this is just a small add-on that allows you to
> seperate between an assert's definition time and testing time.
> It's useful when an assert needs to compare some new value to an
> "old" value (usually solved by saving the old value in a temp
> variable, which I find messy).

Sounds great to me.

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