|
Boost : |
From: Moore, Paul (paul.moore_at_[hidden])
Date: 2000-11-20 11:07:42
From: Jeremy Siek [mailto:jsiek_at_[hidden]]
> > You have used a do{}while loop to scope your dummy variable, is this
> > actually required? Could you not just use:
> >
> > #define REQUIRE(__type_var, __concept) \
> > { \
> > void (__concept##_concept <__type_var>::*__x)() = \
> > BOOST_FPTR __concept##_concept <__type_var>::constraints; \
> > (void) __x; }
>
> I used do{}while out of habit... just {} should be fine.
The usual reason for do...while is that {...} is not "quite" a statement.
Example
#define test1 do { int n = 2; (void)n } while (0)
#define test2 { int n = 2; (void)n }
if (0)
test1;
else
/* whatever */;
if (0)
test2;
else
/* whatever */;
The second fails (dangling else) as test2; expands to {...}; and the extra ;
is a null statement which stops the else from coming straight after the
if...
I'm depressed that I know this...
Paul.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk