Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-01-23 16:28:44


On Jan 23, 2004, at 3:13 PM, Jonathan Turkanis wrote:

> What is your view on conversions which add cv-qualification?

As long as your asking... ;-)

I see no problem with:

move_ptr<T> p;
move_ptr<const T> pc(move(p));

but not vice-versa (just like raw pointers).

I also like Rani Sharoni's suggestion of restricting the member
template conversion constructors to those template arguments that would
actually work:

Begin forwarded message:

> From: Rani Sharoni <rani_sharoni_at_[hidden]>
> Date: January 11, 2004 9:18:49 AM EST
> To: boost_at_[hidden]
> Subject: [boost] Overloading based on smart pointers
> Reply-To: Boost mailing list <boost_at_[hidden]>
>
> Consider the following:
> #include "boost/shared_ptr.hpp"
>
> struct B {};
> struct D : B {};
>
> void f(boost::shared_ptr<B>); // #1
> void f(boost::shared_ptr<int>); // #2
>
> int main()
> {
> boost::shared_ptr<D> dp(new D);
> f(dp); // #3 ambiguous call to overloaded function
> }
>
> #3 yield ambiguity since #1 and #2 have the same UDC rank using
> converting
> constructor regardless of further constraints (i.e. D* is convertible
> to
> B*).
> This problem is common to classes that has generalized copy/converting
> constructor and can be avoided using extra default parameter and
> SFINAE. I
> vaguely remember that I saw this technique in the new iterator adapter.
>
> Thanks,
> Rani

-Howard


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