Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-07-21 18:17:21


From: "Itay Maman" <itay_maman_at_[hidden]>

> "David Abrahams" <david.abrahams_at_[hidden]> wrote in message
> news:144a01c230d8$2d942d30$6501a8c0_at_boostconsulting.com...
> >
> > From: "Itay Maman" <itay_maman_at_[hidden]>
> >
> > > >
> > > > template <class T, class U>
> > > > whatever extract(variant<U> const&, boost::type<T>* = 0);
> > > >
> > > This Practically creates two different interfaces: Code written for
GCC
> > (for
> > > example) will not work under MSVC since all the
> > > "extract<T>(x);" calls will not work. (I'd be glad to stand corrected
if
> > > this is not the case).
> >
> > Then so stand.
> > I do this all the time and it works fine with GCC.
> > Why did you think it wouldn't work?
> >
> The problem is on the opposite direction. Consider this piece:
> using boost::extract;
> boost::variant<int, double> v;
> int* p = extract<int>(&v);
really?---------------------^
>
> It works fine with GCC, but breaks MSVC.

Patient: "Doctor, it hurts when I do this..."
Doctor: "So don't do that..."

So you can't expect using-declarations to work with MSVC. If you need to
write portable code, do something else, e.g.:

using namespace boost::variants;
variant<int,double> v;
int* p = extract<int>(v);

Another solution for things like this that ought to be found via Koenig
lookup anyway is just to stick them in the global namespace for MSVC.

-Dave


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