Boost logo

Boost :

From: Dirk Gerrits (dirk_at_[hidden])
Date: 2003-03-11 11:46:17


Gennaro Prota wrote:
> On Mon, 10 Mar 2003 20:41:26 -0800, "Jaap Suter"
> <J.Suter_at_[hidden]> wrote:
>
>
>>>#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.
>>
>>That seems indeed the best solution to me (with the __LINE__ included) as
>>most of the time is spend in calculations for the actual expression.
>
>
> In effect I would prefer the one without __LINE__. But if any compiler
> warns about duplicate typedefs than it's better having a single
> version, with __LINE__, than #ifs.
>
> Also I have a slight preference for using void instead of char, as
> suggested by Greg:
>
>
> typedef void boost_static_assert_typedef

Perhaps I missed a part of the discussion, but what is wrong with Jaap's
suggestion:

#ifdef BOOST_STATIC_NDEBUG
     #define BOOST_STATIC_ASSERT( B ) BOOST_STATIC_ASSERT_IMPL( true )
#else
     #define BOOST_STATIC_ASSERT( B ) BOOST_STATIC_ASSERT_IMPL( B )
#endif

?

>>>But all this conjectures
>>>should be backed up by some measurement. Jaap?
>>
>>Agreed. I will do some measurements this week and report back in a few days.
>
>
> Nice :-)

Indeed. :)

Dirk Gerrits


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk