From: Darren Cook (darren_at_[hidden])
Date: 2003-05-02 03:05:05
>>>assert( (i < j) || (i == 0) || (j == 1) ); would change into
>>>SMART_ASSERT( (v_(i) < v_(j)) || (i == 0) || (j == 1) );
>>INVARIANT( (i < j) || (i == 0) || (j == 1)) (i) (j) ;
> This would look incredibly cool!
> However, I spent some time, and I don't know how to implement it.
I don't know either, but I agree it would be very nice to have.
For the name I prefer SMART_ASSERT (or your original OP_ASSERT) - it tells
me (or the next programmer) that I'm just using a fancy kind of assert with
all that implies (if condition is false there is a programmer error; no
Up until now I've used my own assert file that basically has lots of macros
ASSERT_EQ, ASSERT_GT, ASSERT_BETWEEN, etc.
After studying Boost.Test code I was planning to modify my code to do some
of the things I learnt there, but I think I'll just wait for your proposal
P.S. Has there ever been interest in adding design-by-contract pre/post
conditions to the C++ language?
Not only would it do away with many of the asserts I have (which slow my
debug version programs down significantly), but they would assert at compile
time instead of run-time, and I wouldn't have to worry about if my test set
covers all the possibilities. (do a web search for the Eiffel language if
you want more advocacy).
But I'm off-topic for Boost - this has to be added at the compiler level to
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk