2022. reference_wrapper<T>::result_type is underspecified

Section: 23.14.5 [refwrap] Status: C++11 Submitter: Daniel Krügler Opened: 2010-12-08 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [refwrap].

View all issues with C++11 status.

Discussion:

Issue 1295 correctly removed function types and references to function types from the bullet 1 of 23.14.3 [func.require] p. 3 because neither function types nor function references satisfy the requirements for a target object which is defined to be an object of a callable type. This has the effect that the reference in 23.14.5 [refwrap] p. 2

reference_wrapper has a weak result type (20.8.2).

is insufficient as a reference to define the member type result_type when the template argument T is a function type.

There are basically two approaches to solve the problem:

  1. Extend the definition of a weak result type in 23.14.3 [func.require] p. 3 to both function types and references thereof. This extension must be specified independend from the concept of a call wrapper, though.

  2. Add one extra sentence to 23.14.5 [refwrap] p. 2 that simply defines the member type result_type for reference_wrapper<T>, when T is a function type.

I checked the current usages of weak result type to have a base to argue for one or the other approach. It turns out, that there is no further reference to this definition in regard to function types or references thereof. The only other reference can be found in 23.14.11.3 [func.bind.bind] p. 3, where g is required to be a class type.

[2011-02-23 Reflector discussion]

Moved to Tentatively Ready after 5 votes.

Proposed resolution:

The suggested wording changes are against the working draft N3242.

  1. Change 23.14.5 [refwrap] p. 2 as indicated:

    2 reference_wrapper<T> has a weak result type (20.8.2). If T is a function type, result_type shall be a synonym for the return type of T.