|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-03-09 20:23:39
Terje Slettebø <tslettebo_at_[hidden]> writes:
>>From: "David Abrahams" <dave_at_[hidden]>
>
>> Dirk Gerrits <dirk_at_[hidden]> writes:
>>
>> > Dirk Gerrits wrote:
>> > >
>> > > I'd say something like:
>> > >
>> > > #ifdef STATIC_NDEBUG
>> > > # define BOOST_STATIC_ASSERT2(e) BOOST_STATIC_ASSERT(e)
>> > > #else
>> > > # define BOOST_STATIC_ASSERT2(e) (void(e))
>> > > #endif
>> > >
>> > > Analogous to <cassert>.
>> >
>> > Argh, the if and else branches should be reversed of course. You've
>> > gotta love negative logic. ;)
>>
>> I like the basic idea, but are you sure it will work in all the
>> contexts where BOOST_STATIC_ASSERT works? I think BOOST_STATIC_ASSERT
>> functions like a declaration, syntactically.
>
> Then how about simply:
>
> #ifndef STATIC_NDEBUG
> # define BOOST_STATIC_ASSERT2(e) BOOST_STATIC_ASSERT(e)
> #else
> # define BOOST_STATIC_ASSERT2(e) // Possibly "void(0)" here, like
> "assert"
> #endif
>
> By the way, what's the point with "void(0)", compared to nothing? Both
> "void(0);" and ";" are valid statements.
is ";" legal where a declaration is expected?
class X
{
; // legal?
};
Comeau says it isn't:
MODE:strict errors C++
"ComeauTest.c", line 3: error: extra ";" ignored,
In C: A function definition does not end with a semicolon
In C++: A function definition, extern "C" or namespace, does not end with a semicolon
; // legal?
^
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk