Skip to content

CWG2846 [dcl.fct] Out-of-line definitions of explicit object member functions #493

Closed
cplusplus/draft
#6906
@sdkrystian

Description

@sdkrystian

Full name of submitter: Krystian Stasiowski

Reference (section label): [dcl.fct]

Link to reflector thread (if any): N/A

Issue description:

According to [dcl.fct] p6:

An explicit-object-parameter-declaration is a parameter-declaration with a this specifier. An explicit-object-parameter-declaration shall appear only as the first parameter-declaration of a parameter-declaration-list of either:

  • a member-declarator that declares a member function, or
  • a lambda-declarator.

A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.

In the following example:

struct A
{
    void f(this A&);
};

void A::f(this A&) { }

The out-of-line definition of A::f is not a member-declarator, therefore it cannot contain an explicit-object-parameter-declaration. However, this is accepted by clang, GCC, EDG, and MSVC.

Suggested resolution:

Replace the first subbullet of [dcl.fct] p6 with:

  • a declaration of a non-static member function, or

Change the final sentence of [dcl.fct] p6 as follows (note: this affects some of the wording touched by CWG2553:

A member-declaratornon-static member function with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions