
"John Maddock" <john@johnmaddock.co.uk> 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.
- 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. 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. -- Dave Abrahams Boost Consulting www.boost-consulting.com