[cfe-dev] static_assert without C++11 and with a message?

Howard Hinnant hhinnant at apple.com
Sat Jun 23 08:07:12 PDT 2012


On Jun 23, 2012, at 9:56 AM, John Bytheway wrote:

> On 20/06/12 05:27, Stephen Kelly wrote:
>> Howard Hinnant wrote:
>> 
>>> On Jun 19, 2012, at 3:22 AM, Stephen Kelly wrote:
>>> 
>>>> 
>>>> Hi there,
>>>> 
>>>> I was looking into libc++, and noticed the implementation of
>>>> static_assert for pre-c++11 compilers.
>>>> 
>>>> Inside of the _LIBCPP_HAS_NO_STATIC_ASSERT ifdef, there is a typo (__t
>>>> should be __m I presume?),
>>> 
>>> Nope.
>> 
>> Ah, I see. I thought you had a clever way of getting the __m message into 
>> the compile error. That's something that I find annoying in Qt because our 
>> C++98 static_assert fallback doesn't contain the error.
> 
> Boost has a C++98 static assert with message, but you
> have_to_make_the_message_a_valid_identifier.
> 
> <http://www.boost.org/doc/libs/1_49_0/libs/mpl/doc/refmanual/assert-msg.html>

<nod> I'd be more motivated to create a perfect static_assert in C++03 mode if -std=c++11 was not just so darned easy and useful for so many things! :-)

Howard




More information about the cfe-dev mailing list