|
Boost : |
From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-03-10 12:33:57
On Sun, 09 Mar 2003 20:23:39 -0500, David Abrahams
<dave_at_[hidden]> wrote:
>is ";" legal where a declaration is expected?
>
>class X
>{
> ; // legal?
>};
No. C++ has a "null statement" (expression-statement without the
expression part) but not no "null declaration". The grammar seems to
allow it but that is incompatible with the semantic restrictions in
clause 7. So, in any context where you can have declarations but not
statements (e.g. namespace scope) you can't put a free semicolon.
Anyway, as Terje says, if the compile-time cost of the static
assertion is mainly in the evaluation of the condition then the
'release mode' definition could simply be
#define BOOST_STATIC_ASSERT(c) \
typedef char boost_static_assert_typedef
When using several asserts in the same context some compilers could
complain about the duplicate typedef; if so pasting the expansion of
__LINE__ shouldn't be that expensive either. But all this conjectures
should be backed up by some measurement. Jaap?
Genny.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk