Files
2025-10-25 03:02:53 +03:00

4.1 KiB
Raw Permalink Blame History

[enum.udecl]

9 Declarations [dcl]

9.8 Enumerations [enum]

9.8.2 The using enum declaration [enum.udecl]

using-enum-declaration:
using enum using-enum-declarator ;

using-enum-declarator:
nested-name-specifieropt identifier
nested-name-specifieropt simple-template-id
splice-type-specifier

1

#

A using-enum-declarator of the form splice-type-specifier designates the same type designated by the splice-type-specifier.

Any other using-enum-declarator names the set of declarations found by type-only lookup ([basic.lookup.general]) for the using-enum-declarator ([basic.lookup.unqual], [basic.lookup.qual]).

The using-enum-declarator shall designate a non-dependent type with a reachable enum-specifier.

[Example 1: enum E { x };void f() {int E; using enum E; // OK}using F = E;using enum F; // OKtemplate using EE = T;void g() {using enum EE; // OK} — end example]

2

#

A using-enum-declaration is equivalent to a using-declaration for each enumerator.

3

#

[Note 1:

A using-enum-declaration in class scope makes the enumerators of the named enumeration available via member lookup.

[Example 2: enum class fruit { orange, apple };struct S {using enum fruit; // OK, introduces orange and apple into S};void f() { S s; s.orange; // OK, names fruit::orange S::orange; // OK, names fruit::orange} — end example]

— end note]

4

#

[Note 2:

Two using-enum-declarations that introduce two enumerators of the same name conflict.

[Example 3: enum class fruit { orange, apple };enum class color { red, orange };void f() {using enum fruit; // OKusing enum color; // error: color::orange and fruit::orange conflict} — end example]

— end note]