Boost logo

Boost :

Subject: Re: [boost] [contract] Broken postconditions on throw
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2012-08-28 15:39:39


On Aug 28, 2012 11:43 AM, "Andrzej Krzemienski" <akrzemi1_at_[hidden]> wrote:
>
> 2012/8/28 Lorenzo Caminiti <lorcaminiti_at_[hidden]>
>
> >
> > > " (7)
> > >
> > > The documentation lists the following sequence for executing a
> > constructor:
> > >
> > > 1. Initialize member variables via the constructor member
> > > initialization list (if such a list is specified).
> > > 2. Check preconditions (but not invariants).
> > > 3. Execute constructor body.
> > > 4. Check invariants.
> > > 5. Check postconditions.
> >
> > Where do the docs say the above? That's incorrect...
> >
>
> Vicente quotes the thread from this list from two years ago. But the
> library has been changed since and executes the expected sequence of
checks
> (preconditions first, initialization second). I already managed to test
> that :)

BTW, to simply test contract execution printf-style, you can print in the
assertions:

precondition( std::clog << ... )

Because the output operator returns a stream that converts to bool true if
no error, so a stream can be used in an assertion and to print if you are
in a given pre/post/inv.

HTH,
--Lorenzo


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