Skip to content

CWG3192 [class.local] An enum nested in local class should be allowed to be defined out-of-line #907

@localspook

Description

@localspook

Full name of submitter: Victor Chernyakin

Issue Description

[class.local]/3 says:

A class nested within a local class is a local class. A member of a local class X shall be declared only in the definition of X or, if the member is a nested class, in the nearest enclosing block scope of X.

Under this wording, defining a struct out-of-line is allowed, but defining an enum is not:

void f() {
  struct X {
    struct S;
    enum E : int;
  };
  struct X::S {}; // okay
  enum X::E : int {}; // ill-formed
}

However, all major implementations accept this code, and there seems to be no reason that it should be disallowed.

Proposed resolution

A class nested within a local class is a local class. A member of a local class X shall be declared only in the definition of X or, if the member is an enumeration or a nested class, in the nearest enclosing block scope of X.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions