
12 Mar
2010
12 Mar
'10
5:34 p.m.
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