This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
future::share()
Section: 32.10.7 [futures.unique.future] Status: C++17 Submitter: Agustín K-ballo Bergé Opened: 2015-11-05 Last modified: 2021-06-06
Priority: 3
View all other issues in [futures.unique.future].
View all issues with C++17 status.
Discussion:
future::share()
is not noexcept
, it has a narrow contact requiring valid()
as per the blanket
wording in [futures.unique_future] p3. Its effects, however, are return shared_future<R>(std::move(*this))
,
which is noexcept
as it has a wide contract. If the source future
isn't valid then the target
shared_future
simply won't be valid either. There appears to be no technical reason preventing future::share()
from having a wide contract, and thus being noexcept
.
[2016-08-03 Chicago]
Fri AM: Moved to Tentatively Ready
Proposed resolution:
This wording is relative to N4567.
Change [futures.unique_future] as indicated:
-3- The effect of calling any member function other than the destructor, the move-assignment operator,
share
, orvalid
on afuture
object for whichvalid() == false
is undefined. [Note: Implementations are encouraged to detect this case and throw an object of typefuture_error
with an error condition offuture_errc::no_state
. — end note]namespace std { template <class R> class future { public: […] shared_future<R> share() noexcept; […] }; }[…]
shared_future<R> share() noexcept;-12- Returns:
-13- Postcondition:shared_future<R>(std::move(*this))
.valid() == false
.[…]