Title
Operator lookup in trailing return type
Status
c++14
Section
12.2.2.3 [over.match.oper]
Submitter
Johannes Schaub

Created on 2013-01-23.00:00:00 last changed 114 months ago

Messages

Date: 2013-09-15.00:00:00

[Moved to DR at the September, 2013 meeting.]

Date: 2013-04-15.00:00:00

Proposed resolution (April, 2013):

Change 12.2.2.3 [over.match.oper] bullet 3.1 as follows:

  • If T1 is a complete class type or a class currently being defined, the set of member candidates is the result of the qualified lookup of T1::operator@ (12.2.2.2.2 [over.call.func]); otherwise, the set of member candidates is empty.

Date: 2017-02-06.00:00:00

There is an unfortunate disparity between the treatment of an example like

  struct S {
    int operator[](int);
    auto f() -> decltype(this->operator[](0));
  };

(which is permitted, cf _N4567_.5.1.1 [expr.prim.general] paragraph 3), and

  struct S {
    int operator[](int);
    auto f() -> decltype((*this)[0]);
  };

which is not. The reason for rejecting the latter is 12.2.2.3 [over.match.oper] paragraph 3:

For a unary operator @ with an operand of a type whose cv-unqualified version is T1, and for a binary operator @ with a left operand of a type whose cv-unqualified version is T1 and a right operand of a type whose cv-unqualified version is T2, three sets of candidate functions, designated member candidates, non-member candidates and built-in candidates, are constructed as follows:

  • If T1 is a complete class type, the set of member candidates is the result of the qualified lookup of T1::operator@ (12.2.2.2.2 [over.call.func]); otherwise, the set of member candidates is empty.

  • ...

It would be desirable to update the latter specification to allow lookup of preceding declarations in a class currently being defined, analogously with the lookup performed in the function-notation case.

History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: drwp -> c++14
2014-03-03 00:00:00adminsetstatus: dr -> drwp
2013-10-14 00:00:00adminsetmessages: + msg4697
2013-10-14 00:00:00adminsetstatus: ready -> dr
2013-05-03 00:00:00adminsetmessages: + msg4314
2013-05-03 00:00:00adminsetstatus: open -> ready
2013-01-23 00:00:00admincreate