A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cplusplus/CWG/issues/515 below:

CWG2869 [expr.prim.this] Restriction on where `this` can appear mishandles local classes · Issue #515 · cplusplus/CWG · GitHub

Reference (section label): [expr.prim.this]

Issue description: [expr.prim.this]/3 says, in part:

[this] shall not appear within the declaration of either a static member function or an explicit object member function of the current class (although its type and value category are defined within such member functions as they are within an implicit object member function).

... which disallows:

struct A {
  static void f() {
    struct B {
      void *g() { return this; }
    };
  }
};

... because this in g() appears within the declaration of A::f, which is a static member function.

Suggested resolution:

Change in [expr.prim.this]/3:

If a declaration declares a member function or member function template of a class X, the expression this is a prvalue of type “pointer to cv-qualifier-seq X” wherever X is the current class between the optional cv-qualifier-seq and the end of the function-definition, member-declarator, or declarator. It shall not appear within The declaration of either that determines the type of this shall declare neither a static member function or nor an explicit object member function of the current class (although its type and value category are defined within such member functions as they are within an implicit object member function).

(See also editorial issue cplusplus/draft#6855.)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4