Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-09-18 16:18:25


"David B. Held" <dheld_at_[hidden]> wrote in message
news:cii44q$ub5$1_at_sea.gmane.org...
> Jonathan Turkanis wrote:
> > [...]
> > Apparently gcc is right. See
> > http://lists.boost.org/MailArchives/boost/msg06980.php.
> >
> > The suggested workaround (maybe that's the wrong term, if it's not a bug)
is:
> >
> > template<class T> struct always_false
> > {
> > enum { value = 0 };
> > };
> >
> > template <typename T>
> > struct foo
> > {
> > void bar(void)
> > {
> > BOOST_STATIC_ASSERT(always_false<T>::value);
> > }
> > };
>
> Ok, thanks. Should the always_false<> template get added somewhere
> permanent, or should we have a special case like
> BOOST_STATIC_ASSERT_FALSE?

I think the latter. Something like:

   namespace boost { namespace detail {
        template<class Dummy> struct always_false
        {
            enum { value = 0 };
        };
   } } // namespace

   #define BOOST_STATIC_ASSERT_FALSE(x) \
       BOOST_STATIC_ASSERT(::boost::detail::always_false< x >::value);

Of course we could also use:

   #define BOOST_STATIC_ASSERT_FALSE(x) \
         BOOST_STATIC_ASSERT((mpl::apply<mpl::always<mpl::false_>, x>::value));

but that seems like overkill.

Jonathan


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