Boost logo

Boost :

Subject: Re: [boost] [static_assert.hpp] Add BOOST_STATIC_ASSERT_MSG?
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2011-01-27 11:26:43


Stewart, Robert wrote:
> Beman Dawes wrote:
>> BOOST_STATIC_ASSERT predated C++0x static_assert, so it doesn't take
>> advantage of static_assert's message argument when static_assert is
>> available.
>>
>> It would break too much code to change BOOST_STATIC_ASSERT, but we can
>> add a new macro that does take advantage of C++0x static_assert if
>> available.
>
> +1
>
>> + #ifndef BOOST_NO_STATIC_ASSERT
>> + # define BOOST_STATIC_ASSERT_MSG( B, Msg ) static_assert(B, Msg)
>> + #else
>> + # define BOOST_STATIC_ASSERT_MSG( B, Msg ) BOOST_STATIC_ASSERT( B )
>> + #endif
>
> The abbreviated "MSG" seems out of place. I realize "BOOST_STATIC_ASSERT_MESSAGE" is very long, but it fits the pattern better. I could make it even worse by suggesting that "BOOST_STATIC_ASSERT_WITH_MESSAGE" would read better, particularly since the message isn't being asserted.

It would be nice to remain consistent boost test practice:

BOOST_WARN_MESSAGE(predicate, message)
BOOST_CHECK_MESSAGE(predicate, message)
BOOST_REQUIRE_MESSAGE(predicate, message)

BOOST_STATIC_ASSERT_MESSAGE(predicate, message)

and didn't Beman just add a

BOOST_ASSERT_MESSAGE(predicate, message)

Jeff


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