|
Boost : |
From: Vesa Karvonen (vesa.karvonen_at_[hidden])
Date: 2001-05-25 01:55:18
From: "Greg Chicares" <chicares_at_[hidden]>
> // alternative enum based implementation:
> #define BOOST_STATIC_ASSERT( B ) \
> enum { BOOST_ASSERT_JOIN(boost_static_assert_enum_, __LINE__) \
> - = sizeof(::boost::STATIC_ASSERTION_FAILURE< ( B ) >) }
> + = sizeof(::boost::STATIC_ASSERTION_FAILURE< ( !!B ) >) }
^^^^^^^
> #endif
The above form is dangerous. The macro parameter should be in parens:
+ = sizeof(::boost::STATIC_ASSERTION_FAILURE< !!( B ) >) }
^^^^^^^
Consider the following code:
BOOST_STATIC_ASSERT(2 == 2);
Which would expand to:
enum { boost_static_assert_enum___LINE__
= sizeof(::boost::STATIC_ASSERTION_FAILURE< ( !!2 == 2 ) >) }
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk