Boost logo

Boost :

From: Miroslav Silovic (miro_at_[hidden])
Date: 2002-10-28 06:41:42


D language wrote:

>No I would not want to do that. When exceptions are thrown, it is very
>likely the postconditions will fail because the program is out of its
>normall control flow. For that same reason, testing postconditions after
>exception is thrown does not make any sence. This makes me think that pre
>and post conditions in constructor/destructor of a class is not such a good
>idea afterall.
>
>I am getting a feeling that there is no practical way of checking pre/post
>conditions with C++ other than the unfortunate self discipline.
>
>
>
Well, exceptions are a part of the method's contract, and I believe they
should be accounted for in the postconditions.

However, I see another problem with pre/postconditions: How do you
implement proper contravariance? That is, on overriden methods, parent's
implementation should be autochecked, plus, the precondition should be
and'ed, and postcondition should be or'ed with those of the parent's
implementation.

    Miro


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