|
Boost : |
Subject: Re: [boost] suggestion on assertion macros
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-03-12 12:34:30
AMDG
DE wrote:
> but to check if the arg converts to bool we can write something like
>
> #define assert(cond) sizeof(bool(cond))
>
#define assert(cond) sizeof(bool(cond))
int main() {
int i = 0;
assert(i);
}
warning C4800: 'int' : forcing value to bool 'true' or 'false'
(performance warning)
> which may or may not expand to some code (i.e. machine instructions)
>
If this isn't completely optimized away, and you actually
care, you should get a better compiler.
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk