Title
std::future<>::share() only applies to rvalues
Status
c++11
Section
[futures.unique.future]
Submitter
Anthony Williams

Created on 2011-02-17.00:00:00 last changed 161 months ago

Messages

Date: 2011-02-22.05:40:42

Proposed resolution:

Alter the declaration of share() to remove the "&&" rvalue qualifier in [futures.unique_future] p. 3, and [futures.unique_future] p. 11:

shared_future<R> share() &&;
Date: 2011-02-22.00:00:00

[ 2011-02-22 Reflector discussion ]

Moved to Tentatively Ready after 5 votes.

Date: 2011-02-17.00:00:00

As specified, future<>::share() has the signature

shared_future<R> share() &&;

This means that it can only be applied to rvalues. One of the key benefits of share() is that it can be used with the new auto facility:

std::promise<some_long_winded_type_name> some_promise;
auto f = some_promise.get_future(); // std::future
auto sf = std::move(f).share();

share() is sufficiently explicit that the move should not be required. We should be able to write:

auto sf = f.share();
History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2011-04-11 11:23:23adminsetstatus: voting -> wp
2011-03-05 15:24:28adminsetstatus: ready -> voting
2011-02-22 05:40:42adminsetmessages: + msg5526
2011-02-22 05:40:42adminsetstatus: new -> ready
2011-02-17 19:34:32adminsetmessages: + msg5506
2011-02-17 00:00:00admincreate