Title
Specify the requirements for promise/future/shared_future consistently
Status
new
Section
[futures.promise]
Submitter
Tomasz Kamiński

Created on 2020-07-18.00:00:00 last changed yesterday

Messages

Date: 2020-08-02.16:30:32

Proposed resolution:

This wording is relative to N4861.

  1. Modify [futures.promise] as indicated:

    namespace std {
      template<class R>
      class promise {
        […]
      };
      […]
    }
    

    -?- For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.

    -1- The implementation provides the template promise and two specializations, promise<R&> and promise<void>. These differ only in the argument type of the member functions set_value and set_value_at_thread_exit, as set out in their descriptions, below.

  2. Modify [futures.unique.future] as indicated:

    namespace std {
      template<class R>
      class future {
        […]
      };
    }
    

    -?- For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.

    -4- The implementation provides the template future and two specializations, future<R&> and future<void>. These differ only in the return type and return value of the member function get, as set out in its description, below.

  3. Modify [futures.shared.future] as indicated:

    namespace std {
      template<class R>
      class shared_future {
        […]
      };
    }
    

    -?- For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.

    -4- The implementation provides the template shared_future and two specializations, shared_future<R&> and shared_future<void>. These differ only in the return type and return value of the member function get, as set out in its description, below.

Date: 2020-08-15.00:00:00

[ 2020-08-02; Daniel comments and provides alternative wording ]

Following the suggestion of Tim Song a revised wording is provided which is intended to replace the currently agreed on wording for LWG 3458.

Date: 2020-07-15.00:00:00

[ 2020-07-26; Reflector prioritization ]

Set priority to 3 after reflector discussions. Tim Song made the suggestion to replace the P/R wording by the following alternative wording:

For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.

Previous resolution [SUPERSEDED]:

This wording is relative to N4861.

Ideally the wording below would use a Mandates: element, but due to the still open issue LWG 3193 the wording below uses instead the more general "ill-formed" vocabulary.

  1. Modify [futures.promise] as indicated:

    namespace std {
      template<class R>
      class promise {
        […]
      };
      […]
    }
    

    -?- If is_array_v<R> is true or is_function_v<R> is true, the program is ill-formed.

Date: 2020-07-18.00:00:00

The resolution of the LWG 3458 clearly specified the requirement that future/shared_future are ill-formed in situations when T is native array or function type. This requirement was not strictly necessary for future<T> as it was already ill-formed due the signature of the get function (that would be ill-formed in such case), however it was still added for consistency of specification. Similar, requirement should be introduced for the promise<T>, for which any call to get_future() would be ill-formed, if T is of array or function type.

[Note: promise<int[10]> is ill-formed for libstdc++ and libc++, see this code]

History
Date User Action Args
2020-08-02 16:30:32adminsetmessages: + msg11422
2020-07-26 12:40:13adminsetmessages: + msg11411
2020-07-19 16:56:49adminsetmessages: + msg11406
2020-07-18 00:00:00admincreate