2030. packaged_task::result_type should be removed

Section: 33.6.10 [futures.task] Status: C++11 Submitter: Anthony Williams Opened: 2010-11-12 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [futures.task].

View all issues with C++11 status.


packaged_task::operator() always returns void, regardless of the return type of the wrapped task. However, packaged_task::result_type is a typedef to the return type of the wrapped task. This is inconsistent with other uses of result_type in the standard, where it matches the return type of operator() (e.g. function, owner_less). This is confusing.

It also violates the TR1 result_of protocol, and thus makes packaged_task harder to use with anything that respects that protocol.

Finally, it is of little use anyway.

packaged_task::result_type should therefore be removed.

[2011-02-24 Reflector discussion]

Moved to Tentatively Ready after 5 votes.

Proposed resolution:

Alter the class definition of packaged_task in 33.6.10 [futures.task] p. 2 as follows:

template<class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)> {
  typedef R result_type;