This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See for the official list.


1153. Type matching in address of overloaded function

Section: 12.3  [over.over]     Status: C++11     Submitter: US     Date: 2010-08-03

[Voted into the WP at the November, 2010 meeting.]

N3092 comment US 68

Overload resolution within the operand of a unary & operator is done by selecting the function “whose type matches the target type required in the context.” The criterion for determining whether the types match, however, is not defined. At least three possibilities suggest themselves:

  1. The types are identical.

  2. The source type can be implicitly converted to the target type.

  3. The expression would be well-formed if the function under consideration were not overloaded.

This question arises for pointer-to-member types, where there is an implicit conversion from a pointer-to-base-member to a pointer-to-derived-member, as well as when the context is an explicit type conversion (which allows, for static_cast, a conversion from pointer-to-derived-member to a pointer-to-base-member and, in the reinterpret_cast interpretation of functional and old-style casts, essentially any conversion).

Notes from the August, 2010 meeting:

CWG observed that the only case in which the types might not match exactly was for pointers to member functions. In this case, the approach should be to ignore the class of which the functions are members and just match (exactly) on the function type.

Proposed resolution (September, 2010):

  1. Change 12.3 [over.over] paragraph 1 as follows:

  2. ...The function selected is the one whose type matches is identical to the function type of the target type required in the context. [Note: That is, the class of which the function is a member is ignored when matching a pointer-to-member-function type. —end note] The target can be...
  3. Change 12.3 [over.over] paragraph 3 as follows:
  4. Non-member functions and static member functions match targets of type “pointer-to-function” or “reference- to-function.” Nonstatic member functions match targets of type “pointer-to-member-function;.the function type of the pointer to member is used to select the member function from the set of overloaded member functions. If a non-static member function is selected, the reference to the overloaded function name is required to have the form of a pointer to member as described in [expr.unary.op].