Skip to content

Member functions object parameters #178

@sdkrystian

Description

@sdkrystian

C++23 adds explicit object parameters. The Implicit object parameter of non-static member functions (i.e. the object the non-static member function was called on) is an implicit first function parameter of type "cv-qualifier-seq T ref-qualifier" (note: special rules apply to functions that have no ref-qualifier with respect to reference binding & value categories) which is used by overload resolution to enforce the semantics of cv-qualified and/or ref-qualified non-static member functions (e.g. void f() const &), as well as to determine the type of *this.

Explicit object parameters allow for this parameter to be specified explicitly (e.g. void f(this const T& self)); such functions are called using the usual member access syntax. Additionally, all member access within the function body must be done through this parameter; the this expression is not valid.

Only msvc has partial support for this feature right now. Regardless, we may want to consider a unified syntax for displaying the type of the object parameter of a non-static member function with a unified syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureSomething new that it should doMetadataAST or Metadata addition/change

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions