This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

### 2031. `std::future<>::share()` only applies to rvalues

Section: 33.10.7 [futures.unique.future] Status: C++11 Submitter: Anthony Williams Opened: 2011-02-17 Last modified: 2021-06-06

Priority: Not Prioritized

View all other issues in [futures.unique.future].

View all issues with C++11 status.

Discussion:

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();

[2011-02-22 Reflector discussion]

Moved to Tentatively Ready after 5 votes.

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() &&;