Boost logo

Boost :

Subject: Re: [boost] [move] unique_ptr converting constructor
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2015-05-05 17:53:52

El 04/05/2015 a las 1:23, Peter Dimov escribió:
> While looking at
> I found that after implementing a converting shared_ptr constructor that
> takes a boost::movelib::unique_ptr, the straightforward code in the
> ticket still fails (with g++ in C++03 mode):
> mystd::shared_ptr<int> get_thing() {
> mystd::unique_ptr<int> r( load_thing() );
> return boost::move( r );
> }
> fail for the unique_ptr<int const> case.

Thanks Peter,

That's because the converting constructor is programed as taking
rv<unique_ptr<U, E>> (similar to unique_ptr<U, E> &&) and that provokes
emulation limitations when returning by value convertible types.

One workaround is to take the argument by value in C++03 compilers, like
you've done in shared_ptr. I'll try to experiment with this approach to
see if improves the situation.



Boost list run by bdawes at, gregod at, cpdaniel at, john at