Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-11-24 13:28:34

Andrei Alexandrescu wrote:
> > The above STATIC_ASSERT_MSG macro can only be used in
> > function scope which highly limits its use. IMHO, an industry
> > strength STATIC_CHECK must be usable at:
> > - namespace,
> > - class, and
> > - function scope.
> I know. The current STATIC_ASSERT has the same drawback.

It doesn't. From
"Note that if the condition is true, then the macro will generate neither
code nor data - and the macro can also be used at either namespace, class or
function scope. When used in a template, the static assertion will be
evaluated at the time the template is instantiated; this is particularly
useful for validating template parameters."

> > So, use "do {...} while (0)" instead of "{ ... }".
> I thought this is self-understood as it is a well-known idiom
> for creating macros. I was actually surprised to see that boost doesn't
> apply this idiom all over, and I was going to complain about that.
> So by this message I am complaining :o).

The idiom is not used in BOOST_STATIC_ASSERT because it would limit the
macro applicability to one particular scope.


Boost list run by bdawes at, gregod at, cpdaniel at, john at