Title
Wide contract for future::share()
Status
c++17
Section
[futures.unique.future]
Submitter
Agustín K-ballo Bergé

Created on 2015-11-05.00:00:00 last changed 89 months ago

Messages

Date: 2016-08-06.20:44:18

Proposed resolution:

This wording is relative to N4567.

  1. Change [futures.unique_future] as indicated:

    -3- The effect of calling any member function other than the destructor, the move-assignment operator, share, or valid on a future object for which valid() == false is undefined. [Note: Implementations are encouraged to detect this case and throw an object of type future_error with an error condition of future_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: shared_future<R>(std::move(*this)).

    -13- Postcondition: valid() == false.

    […]

Date: 2016-08-03.00:00:00

[ 2016-08-03 Chicago ]

Fri AM: Moved to Tentatively Ready

Date: 2015-11-05.00:00:00

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.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-06 20:44:18adminsetmessages: + msg8437
2016-08-06 20:44:18adminsetstatus: new -> ready
2015-12-08 20:02:14adminsetmessages: + msg7628
2015-11-05 00:00:00admincreate