Title
Use of this in a late-specified return type
Status
c++11
Section
_N4567_.5.1.1 [expr.prim.general]
Submitter
Alisdair Meredith

Created on 2009-07-18.00:00:00 last changed 130 months ago

Messages

Date: 2011-03-15.00:00:00

Proposed resolution (March, 2011):

This issue is resolved by the resolution of issues 1017 and 1207 in document N3282.

Date: 2010-10-15.00:00:00

Additional note (October, 2010):

The question should also be considered for parameter types; for example,

class comparable {
public:
   bool is_equal(decltype(*this) other) { // should be X&
       return /*...*/;
   }
};
Date: 2010-10-18.00:00:00

(Moved from issue 760.)

Although it was considered and rejected as part of issue 643, more recent developments may argue in favor of allowing the use of this in a late-specified return type. In particular, declaring the return type for a forwarding function in a derived class template that invokes a member function of a dependent base class is difficult without this facility. For example:

    template <typename T> struct derived: base<T> {
      auto invoke() -> decltype(this->base_func()) {
        return this->base_func();
      }
    };

(See also issue 1207 for another potential motivation for a change to this rule.)

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3309
2011-04-10 00:00:00adminsetstatus: open -> fdis
2010-10-18 00:00:00adminsetmessages: + msg3017
2009-07-18 00:00:00admincreate