Boost logo

Boost :

From: Csaba Szepesvari (szepes_at_[hidden])
Date: 1999-12-16 05:45:10


> I'm not sure why the class has to be named. I found that this variant of
> your implementation works well, but I'm not sure that it's portable.
>
> namespace boost
> {
> #define CTASSERT(condition) struct { enum { \
> check = ::boost::compile_time_assert<condition>:: \
> compile_time_assertion_failed }; }
>
> template<bool> struct compile_time_assert;
> template<> struct compile_time_assert<false> { };
> template<> struct compile_time_assert<true>
> { enum { compile_time_assertion_failed}; };
> }
>

This does not work on VC 5.0/6.0 SP3 in class declarations, but produces the
error message C2625.
When used in an implementation body, the compiler generates a warning.
I would also like to remove the requirement to name the class, of course.

> I think the name CTASSERT is cryptic, although it's good that it's short.
>
> The original implementation had an extra semicolon in the definition of
> CTASSERT which made it an error to have another semicolon after it when it's
> in a declaration. I removed the semicolon.
>
> The specializations of the compile_time_assert struct did not use the
> "template<>" syntax, so I added that.
>

Thanks for the other comments.

- Csaba


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