Boost logo

Boost :

From: Bjorn.Karlsson_at_[hidden]
Date: 2002-04-29 05:31:44


> From: Markus Schöpflin [mailto:markus.schoepflin_at_[hidden]]
> The example I gave in my first post shows such a case and
> it's not a contrieved example.

I agree. I don't think it's a common situation, but it's a perfectly valid
use case, and the obvious fix is to make the constructor explicit. It's just
that the fix is accompanied by implications, some of them unpleasant.
 
> > Sure it does. The change makes it easier to write illegal
> code that works with this compiler.
>
> I don't follow you here.

If we consider the explicit constructor being an option, not a fix for an
error, than that option on this particular compiler will allow illegal code
to "work". I admit this is not a strong argument - it's just a reflection.
 
> >
> > With an explicit templated constructor for any, on a
> popular compiler, the following doesn't compile:
> >
> > boost::any a(5);
> >
> > std::vector<boost::any> vec;
> > vec.push_back(a); // doesn't work - cannot convert from
> const boost::any etc...
>
> Could you name the compiler? My usual suspect (MSVC) does the
> right thing in this case.

Your ususal suspect.NET ;-)

Bjorn Karlsson



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