|
Boost : |
From: Darren Cook (darren_at_[hidden])
Date: 2004-01-02 01:41:23
>> 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 :-).
> 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?
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);
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);
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk