Boost logo

Boost :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-09-20 11:47:26


Jonathan Turkanis <technews_at_[hidden]> wrote:
> "Robert Ramey" <ramey_at_[hidden]> wrote in message
> news:20040919040443.D18A931132_at_acme.west.net...
> > "David B. Held" <dheld_at_[hidden]> wrote in message
> > news:cihmvu$3ik$1_at_sea.gmane.org...
> > > #include <boost/static_assert.hpp>
> > >
> > > template <typename T>
> > > struct foo
> > > {
> > > void bar(void)
> > > {
> > > BOOST_STATIC_ASSERT(false);
> > > }
> > > };
> >
> > I use
> >
> > ....
> > BOOST_STATIC_ASSERT(sizeof(T) == 0);
>
> The expression 'always_false<T>::value' can't be evaluated until
> the point of instantiation, since always_false could be
> specialized for T. OTOH, the compiler can tell immediately that
> 'sizeof(T) == 0' is false, so might it not replace
> 'sizeof(T) == 0' with 'false', and then issue the same error as
> in the quoted case?

sizeof(T) isn't always false, because for some types T it isn't
even well-formed. As a value-dependent expression I think it must
not be evaluated until the template is instantiated.


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