Boost logo

Boost :

From: Johan Paulsson (boost.org_at_[hidden])
Date: 2006-11-09 09:49:50


David Abrahams wrote:
> "John Maddock" <john_at_[hidden]> writes:
>
>> Johan Paulsson wrote:
>>> I wrote:
>>>> Below is the compile-time assert I use.
>>>> Would it be a useful addition to Boost?
>>> To make it easier to digest, I put together a minimal web page with
>>> - Source code
>>> - A test
>>> - Compiler errors from the test, using different compilers (It's
>>> supposed to make compiler errors). Compiler errors from the same test
>>> using BOOST_STATIC_ASSERT, BOOST_MPL_ASSERT and BOOST_MPL_ASSERT_MSG
>>> is
>>> also included, to make it easy to compare.
>>>
>>> I think the benefits of my compile time assert is:
>>> - No macros
>
> I don't think that's a very significant advantage.
>

You are right, thank you for pointing that out.

>>> - No compiler-specific implementation
>>> - It's easy to make useful error-messages
>>>
>>> Please have a look at <http://www.kuodo.com/code/assert/readme.html>
>>>
>>> Or download it (12kb) <http://www.kuodo.com/code/assert/assert.zip>
>>
>> Frankly it's hard to choose between them on error message quality (which is
>> to say none are all that good).
>
> I think you'd see a much bigger difference in quality if there were a
> deep instantiation backtrace. With the MPL asserts, the failing
> condition shows up in the error message itself, rather than in a
> backtrace frame, which (on GCC for example) can be far, far away from
> the top of the output.

I collected some more compiler output. It's not extremely deep but the
typenames are long. I hope this is closer to what you would like to see:

Directory listing: <http://www.kuodo.com/code/assert/deep>
Download (19kb): <http://www.kuodo.com/code/assert/deep/deep.zip>

Please note this is plain text, no html. The "readme.txt" file should
explain what the other files contain.

In this case, with the compilers I used, I do not see a big difference
in quality of the error message.

> Also, the first test, which simply asserts a bool constant, is not
> very interesting from an error-message-quality point of view. You
> can't expect much useful information from such an assertion; it's
> similar to
>
> assert(false);
>
> at runtime.
>

I agree, I should have left it out of the compiler output.

/Johan Paulsson


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