Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-10-09 04:34:59


Alexander Nasonov ha escrito:

> Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
>
> > OK, I think I've got it: MSVC++ 6.5 behaves funny with static constants
> > inside templates, as it does not see their correct value during template
> > parsing. For instance, the following:
> >
> > #include <boost/config.hpp>
> > #include <boost/static_assert.hpp>
> >
> > template<typename T>
> > struct foo
> > {
> > BOOST_STATIC_CONSTANT(int,x=2);
> > BOOST_STATIC_ASSERT(x==2);
> > };
> >
> > int main()
> > {
> > return 0;
> > }
> >
> > fails at the static assertion line (x is seen as 1, btw). After
> > instantiation, however, the static constant holds the correct value,
> > this phenomenon only happens at the parsing stage.
>
> Does this change
>
> BOOST_STATIC_ASSERT(foo<T>::x==2); // qualified name
>
> help?
>

No, same assertion failure :(

> > Is it OK to commit?
> I'd rather disabled compile-time calculation.

The decision is yours to make, of course, but disabling the static assertions
seems to suffice --the compile-time calculations are indeed OK and hold
correct values once lcast_precision is instantiated.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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