Opened 6 years ago

#12351 new Patches

boost::make_shared doesn't use constructor forwarding through move emulation

Reported by: me@… Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

Currently, boost::make_shared doesn't perform constructor forwarding unless C++11 r-value references are supported. This prevents using of MOVABLE_BUT_NOT_COPYABLE types as arguments to constructors.

The Boost.Move documentation describes how to perform (limited) constructor forwarding. It's example is perfectly applicable to boost::make_shared.

The change in boostorg/smart_ptr#24 implements constructor forwarding for make_shared as documented in Boost.Move's documentation.

With this change the difference between the code supporting r-value references but not supporting variadic templates became the type signature and the call to boost::detail::sp_forward and boost::forward. The first difference was eliminated by using the macro BOOST_FWD_REF, the second by using boost::forward in both places, making the two pieces of code textually equal and thus I also removed the duplicate.

Attachments (1)

0001-boost-make_shared-use-Constructor-Forwarding-on-C-03.patch (35.2 KB ) - added by me@… 6 years ago.
patch boostorg/smart_ptr#24 adding (partial) constructor forwarding on C++03

Download all attachments as: .zip

Change History (1)

by me@…, 6 years ago

patch boostorg/smart_ptr#24 adding (partial) constructor forwarding on C++03

Note: See TracTickets for help on using tickets.