Opened 10 years ago

Closed 9 years ago

#8384 closed Feature Requests (invalid)

Make shared_ptr movable

Reported by: viboes Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

std::shared_ptr is movable. I would be nice if boost::shared_ptr provides the same interface and use Boost.Move to make the code portable to non c++11 compilers.

shared_ptr(shared_ptr&& r) noexcept;
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
20 Remark: The second constructor shall not participate in overload resolution unless Y* is convertible
to T*.
21 Effects: Move-constructs a shared_ptr instance from r.
22 Postconditions: *this shall contain the old value of r. r shall be empty. r.get() == 0.

...

shared_ptr(shared_ptr&& r) noexcept;
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
20 Remark: The second constructor shall not participate in overload resolution unless Y* is convertible
to T*.
21 Effects: Move-constructs a shared_ptr instance from r.
22 Postconditions: *this shall contain the old value of r. r shall be empty. r.get() == 0.

Change History (7)

comment:1 by Peter Dimov, 10 years ago

boost::shared_ptr already provides this.

in reply to:  1 comment:2 by viboes, 10 years ago

Replying to pdimov:

boost::shared_ptr already provides this.

I see the C++11 implementation. Is the Boost.Move emulation provided?

comment:3 by Peter Dimov, 10 years ago

No. Why do you need it?

comment:4 by viboes, 10 years ago

Boost.Thread uses boost::shared_ptr, and the code will be more homogeneous if shared_ptr implemented move semantics using Boost.Move.

comment:5 by Peter Dimov, 10 years ago

Can you give me a specific example?

comment:6 by John Maddock, 9 years ago

(In [85987]) Merge accumulated patches from Trunk. Refs #8384, Refs #8855, refs #9107, refs #9109, refs #8333, refs #8621, refs #8732, refs #8733, refs #8837, refs #8940, refs #9042, refs #9087, refs #9104, refs #9126.

comment:7 by Peter Dimov, 9 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.