std::future::share - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::future::share

From cppreference.com
< cpp‎ | thread‎ | future

std::shared_future<T> share(); |  |

Transfers the shared state of *this, if any, to a std::shared_future object. Multiple std::shared_future objects may reference the same shared state, which is not possible with std::future.

After calling `share` on a std::future, valid() == false.

### [edit] Parameters

(none)

### [edit] Return value

A std::shared_future object containing the shared state previously held by *this, if any, constructed as if by std::shared_future<T>(std:move(*this)).

### [edit] Exceptions

`noexcept` specification:
noexcept

### [edit] Example

| This section is incomplete Reason: no example

### [edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR | Applied to | Behavior as published | Correct behavior
--- | --- | --- | ---
LWG 2556 | C++11 | `share()` requires `valid()` to be `true` | requirement removed and made `noexcept`

### [edit] See also

shared_future (C++11) | waits for a value (possibly referenced by other futures) that is set asynchronously (class template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/thread/future/share&oldid=91556"
Categories:

- unconditionally noexcept
- Todo no example

Hidden categories:

- Pages with unreviewed unconditional noexcept template
- Pages with unreviewed noexcept template