|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2008-06-23 20:47:13
David Abrahams wrote:
> Beman Dawes wrote:
> ...
>> Also, C++0x static_assert is becoming available in more compilers;
>> should all of the Boost compile-time asserts use C++0x static_assert if
>> available?
>
> Without knowing anything about how good the error messages are that one
> gets from static_assert, I'd say "probably."
Sample program:
int main()
{
static_assert(1+1==3, "Everyone knows 1+1 == 4");
return 0;
}
Output from a beta compiler:
temp3.cpp:
Error E2538 temp3.cpp 3: Static assert failed: 'Everyone knows 1+1 ==
4' in function main()
*** 1 errors in Compile ***
That's what I'd expect from most compilers; the file name and line
number of the failure, and an echo of the second argument to static_assert.
So it comes down to writing informative error messages. I like the ones
that say both what is wrong and what to do to fix it, but that's often
hard to do in limited space.
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk