Boost logo

Boost :

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

John Maddock wrote:
> Johan Paulsson wrote:
>> I wrote:
>>> Below is the compile-time assert I use.
>>> Would it be a useful addition to Boost?

8>< snip

> Frankly it's hard to choose between them on error message quality (which is
> to say none are all that good).
> One of the requirements that came up for static asserts when
> BOOST_STATIC_ASSERT was talked about was a declaration like syntax, in fact
> both:
> static_assert<condition> x;
> and
> typedef static_assert<condition> x;
> were explicitly rejected at the time.

Thank you for looking. I prefer some kind of template, but I now realize
most do not.

> I also seem to remember that some compilers at the time evaluated typedefs
> in a lazy manner: if the typedef was unused then it was never evaluated and
> the static-assertion was never triggered. That's the reason for some of the
> convolutions inside static_assert.hpp. I suspect, however, that current
> compilers have moved away from such "lazyness".

That would make my implementation useless.

I think it would be interesting to know that a compile-time assert
should work on any standard-conforming compiler. I don't know if, for
example, typedef-ining an invalid type inside a function, and then not
using the type, makes the program "ill formed" and requires a
"diagnostic message".

Maybe the complie-time asserts in Boost should work on any
standard-conforming compiler. I think that would be a good reason to use
Boost and not mine.

/Johan Paulsson

Boost list run by bdawes at, gregod at, cpdaniel at, john at