Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-05 06:43:44


Hartmut Kaiser wrote:

>>#ifdef _DEBUG
>># define verify(x) do{if(!((x)))asm int 3;}while(0)
>>#else
>># define verify(x) (void)(0)
>>#endif

>> #include "verify.hpp"
>> #include <stdio.h>
>> char first_char( char const * s )
>> {
>> verify( s && ::strlen(s) ); //<-stops right on it ;-)
>> return s[0];
>> }

> That's more or less the same as contained in almost every <assert.h> header.
> So what's new with your suggestion?

asm int 3

assert() terminates the program and displays a stupid message.

verify() works like a Break-Point, it just stops on the line that failed
to verify, and you can look at the variables, change them; you can
choose to single-step from there. And without the __FILE__ and __LINE__
macros, it's a lot more ligthweight... *Use by the thousands!*

The only problem with it is that it breaks the C/C++ tradition of naming
things something completely removed from what they actually do... :)

Cheers!


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