|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-11-02 08:32:30
----- Original Message -----
From: <helmut.zeisel_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, November 02, 2001 7:20 AM
Subject: [boost] Re: numeric_cast, VC++ 6.0, specialization.
> --- In boost_at_y..., "Fernando Cacciola" <fcacciola_at_g...> wrote:
> >
> > ----- Original Message -----
> > From: <helmut.zeisel_at_a...>
>
> >
> > NOTE: I discovered a bug (?) either with gcc2.92.2 or bcc32 5.5.1:
> >
> > Consider:
> >
> > template<class T>
> > struct A
> > {
> > static const int v0 = 0 ;
> >
> > static const int v1 = ::A::v0 ;
> > } ;
> >
> > If my interpretation of [14.6.1] is correct, ::A::v0 is legal since
> A is
> > equivalent to A<T>.
> > Borland agrees with my interpretation.
> >
> > However, gcc doesn't: it requires you to explicitely qualify A as
> in:
> > ::A<T>::v0
> >
> > The problem is that bcc crashes with an internal compiler error if I
> add the
> > <T>.
>
> I do not now either who is right, but maybe the following
> work around could help:
>
> typedef A<T> self_type;
> static const int v1 = self_type::v0;
>
I tried this too, but Borland complained.
Sometimes it requires the full qualification syntax, and in that case it
fails to see self_type.
>
> Using your new version, I get now the following error message
> for the program below (compiled with GCC 3.0.1,
> c++ -DNEW_NUMERIC_CAST;
> compilation with the old numeric_cast works)
>
> hz.cpp: In function `int main()':
> hz.cpp:10: no matching function for call to
> `numeric_cast(double&)'
>
> Helmut
>
> ----- Code exeample ----
> #ifdef NEW_NUMERIC_CAST
> #include <boost/numeric_cast.hpp>
> #else
> #include <boost/cast.hpp>
> #endif
> #include <iostream>
> int main()
> {
> double d=5;
> int j = ::boost::numeric_cast<int>(d);
> }
>
Sad.
Does this compile?
int main()
{
double d=5;
typedef ::boost::numeric_cast_traits<int,double> traits ;
int j = traits::converter::cvt(d);
}
Thanks,
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk