Boost logo

Boost :

Subject: Re: [boost] [contract] Released Contract Programming Library on SourceForge
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2010-02-28 16:57:29

> I have released on SourceForge a library that implements Contract
> Programming (a.k.a. Design by Contract(TM) ) for C++. I am considering
> to submit this library to Boost (as Boost.Contract).
> Comments?

Just another thought for a tiny extension that came to my mind. I
tried to use the block invariant as a regular assert:

  int main() {

This code compiles and works fine. This is because "disabling block
invariants" means that the entire macro invocation will disappear,
inclusive of the nonsense I wrote inside. We are used to it because
this is how C-style asserts work, but one of the advantage of asserts
over comments, as it is often advertised, is that the predicates are
checked for syntactic and (to some extent) semantic correctness. But
this is not the case if we disable the assertion macros.
I believe, it would be useful if "disabling block invariants" meant no
run-time overhead, but still checking syntactic correctness. It would
be possible if the macro


were replaced with something like:

  ... sizeof( expression ) ...

then, the expression is not evaluated, but required to be correct. If
the value of sizeof is not used it should be eliminated by the
compiler. Obviously, the same would be applicable for all the other
types of checks,


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