A RetroSearch Logo

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

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/expr.prim.this below:

[expr.prim.this]

8 Expressions [expr] 8.1 Primary expressions [expr.prim] 8.1.2 This [expr.prim.this]

The keyword this names a pointer to the object for which a non-static member function is invoked or a non-static data member's initializer ([class.mem]) is evaluated.

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” between the optional cv-qualifier-seq and the end of the function-definition, member-declarator, or declarator. It shall not appear before the optional cv-qualifier-seq and it shall not appear within the declaration of a static member function (although its type and value category are defined within a static member function as they are within a non-static member function). [Note: This is because declaration matching does not occur until the complete declarator is known. end note] Unlike the object expression in other contexts, *this is not required to be of complete type for purposes of class member access outside the member function body. [Note: Only class members declared prior to the declaration are visible. end note] [Example:

struct A {
  char g();
  template<class T> auto f(T t) -> decltype(t + g())
    { return t + g(); }
};
template auto A::f(int t) -> decltype(t + g());

end example]

The expression this shall not appear in any other context. [Example:

class Outer {
  int a[sizeof(*this)];                 unsigned int sz = sizeof(*this);    
  void f() {
    int b[sizeof(*this)];             
    struct Inner {
      int c[sizeof(*this)];               };
  }
};

end example]


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