Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2001-11-24 13:18:15


> I use
>
> typedef char error_message_here[expr];
>
> Not as elegant as a macro and doesn't use int2type, granted. ;-)

Some compilers would accept 0-sized arrays. Some others accept -1-sized
arrays.

By the way, in the end I settled on:

#define STATIC_ASSERT_MSG(b, msg) \
    { \
        struct msg \
        { \
            msg(::boost::loki::int2type<true>) {} \
        } msg((::boost::loki::int2type<(b) != 0>())); \
    }

which works like a charm. The way things seem to be, though, it looks like
nobody would be interested in adding something like that to boost.

Andrei


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