3.11.0-rc 3.10.0 (latest) 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 2.10.1 Implement ISO/IEC TS 19571:2016 `future<T>`.

## Constructors

### future()

### future(future\< future\< T \> \> \&\&)

Creates a new future that unwraps `rhs`.
This constructor creates a new shared state that becomes satisfied when both `rhs` and `rhs.get()` become satisfied. If `rhs` is satisfied, but `rhs.get()` returns an invalid future then the newly created future becomes satisfied with a `std::future_error` exception, and the exception error code is `std::future_errc::broken_promise`.

> [!NOTE]
> **Note:** The technical specification requires this to be a `noexcept` constructor I (coryan) believe this is a defect in the technical specification, as this *creates* a new shared state: shared states are dynamically allocated, and the allocator (which might be the default `operator new`) may raise.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `rhs` | `future< future< T > > &&` |

### future(future\< U \> \&\&)

Creates a future from a future whose result type is convertible to this future's result type.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `rhs` | `future< U > &&` |
| `class U` |   |
| `typename Enable` |   |

### future(std::shared_ptr\< shared_state_type \>)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `state` | `std::shared_ptr< shared_state_type >` |

## Functions

### get()

Waits until the shared state becomes ready, then retrieves the value stored in the shared state.

> [!NOTE]
> **Note:** This operation invalidates the future, subsequent calls will fail, the application should capture the returned value because it would.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `...` | any exceptions stored in the shared state. |
| `std::future_error` | with std::no_state if the future does not have a shared state. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

### then(F \&\&)

Attach a continuation to the future.
Attach a callable *func* to be invoked when the future is ready. The return type is a future wrapping the return type of *func*.

Side effects: `valid() == false` if the operation is successful.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `func` | `F &&` a Callable to be invoked when the future is ready. The function might be called immediately, e.g., if the future is ready. |
| `typename F` |   |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `future< >` | `future<T>` where T is `std::result_of_t<F, R>` (basically). If T matches `future<U>` then it returns `future<U>`. The returned future will contain the result of *func*. |

## Type Aliases

### shared_state_type

**Alias Of** : `typename internal::future_base< T >::shared_state_type`