Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-02 06:57:57


Darren Cook wrote:

>>> Has there been any discussion regarding an invariants library
>>> (advanced assert), or is there one already implemented in boost?
> There is smart-assert by John Torjo
> (http://www.torjo.com/smart_assert.zip) which might end up being
> submitted for Boost review. I've been using it on some projects for a
> few months now and find it useful. If only there was a way to generate a
> stack trace I might never need to use a debugger again :-).

I'll check it out.

>> The compiler I'm using, Digital Mars version 8.38 already supports
>> invariant, pre- and post-conditions. See...
>> http://www.digitalmars.com/ctg/designbycontract.html
> Are there any other compilers planning to use these?

Donno.

> Is it working under the hood by generating assert commands, or doing
> compile-time checking? E.g. would the square_root() example (included
> below) create a compile-time error for this?
> square_root(-1);

Good question! I'm not sure, as I've only started using Digital Mars a
couple of months ago and have been too busy to try the DBC features...
(shame on me!, that was the main reason I got DMC).

> If so, what about this:
> void myfunc(long n){
> square_root(n);
> }
>
> myfunc(-1);
>
>
> Darren
>
>
> *:
> long square_root(long x)
> __in
> {
> assert(x > 0);
> }
> __out (result)
> {
> assert((result * result) == x);
> }
> __body
> {
> return sqrt(x);
> }
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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