std::experimental::future<T>::future
From cppreference.com
< cpp | experimental | future
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Experimental
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Extensions for concurrency
std::future extensions
Latches and barriers
Atomic smart pointers
future() noexcept;
(1)
future( std::experimental::future <T>&& f ) noexcept;
(2)
future( const std::experimental::future <T>& ) = delete;
(3)
future( std::experimental::future <std::experimental::future <T>> && other ) noexcept;
(4)
1) Default constructor. Constructs an empty
future object that does not refer to a shared state.2) Constructs a
future object, transferring the shared state held by f, if any. After construction, f.valid() is false.3) Copy constructor is deleted.
future cannot be copied.4) Unwrapping constructor. Constructs a
future object from the shared state referred to by other, if any. If other.valid() == false prior to this call, the constructed future object is empty. Otherwise, the resulting future object becomes ready when one of the following happens:
- other and other.get() are both ready. The value or exception from other.get() is stored in the shared state associated with the resulting
futureobject. - other is ready, but other.get() is invalid. An exception of type std::future_error with an error condition of std::future_errc::broken_promise is stored in the shared state associated with the resulting
futureobject.
After this constructor returns, valid() is equal to the value of other.valid() prior to this call, and other.valid() == false.
Contents
[edit] Parameters
f
-
another future object to initialize with
other
-
a
std::experimental::future object to unwrap
[edit] Example
This section is incomplete
Reason: no example
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 2697 | Concurrency TS | behavior of unwrapping constructor is unclear with an invalid future
|
constructs an empty future
|