Skip to content

US043 06.08 [basic.def].2.17 "using enum" feature is too subtle #42

@wg21bot

Description

@wg21bot

06.08 [basic.def] 9 [dcl.dcl] 9.1.8.3 [dcl.type.elab] 9.6.2 [enum.udecl] 9.8 [namespace.udecl] 11.3 [class.mem] 15.10 [cpp.predefined]

The syntax of the using enum feature is very subtle, which may be confusing to users. Consider, for example:

struct B {
protected:
  enum class E { e1, e2 };
};

class D1 : public B {
public:
  using B::E;
  // Creates a public member using
  // declaration in 'D1' for 'B::E'.
};

class D2 : public B {
public:
  using enum B::E;
  // Creates a public member using    
  // declarations in 'D2' for
  // 'E::e1' and 'E::e2'.
};

void f() {
  D1::E v1; // Ok
  D2::E v2; // COMPILE FAILURE
  D1::e1;   // COMPILE FAILURE
  D2::e2;   // Ok
}

Additionally, the syntax looks similar to elaborated type specifiers, which may also lead to confusion. Please reconsider this feature; it was added very late in the C++20 design process, and it may be better to move it to C++23 to give us more time to work on the design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionrejectedNo consensus for a change.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions