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

64 lines
4.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[enum.udecl]
# 9 Declarations [[dcl]](./#dcl)
## 9.8 Enumerations [[enum]](enum#udecl)
### 9.8.2 The using enum declaration [enum.udecl]
[using-enum-declaration:](#nt:using-enum-declaration "9.8.2The using enum declaration[enum.udecl]")
using enum [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2The using enum declaration[enum.udecl]") ;
[using-enum-declarator:](#nt:using-enum-declarator "9.8.2The using enum declaration[enum.udecl]")
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3Qualified names[expr.prim.id.qual]")opt [*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]")
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3Qualified names[expr.prim.id.qual]")opt [*simple-template-id*](temp.names#nt:simple-template-id "13.3Names of template specializations[temp.names]")
[*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9Type splicing[dcl.type.splice]")
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8118)
A [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2The using enum declaration[enum.udecl]") of
the form [*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9Type splicing[dcl.type.splice]") designates the same type designated by the [*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9Type splicing[dcl.type.splice]")[.](#1.sentence-1)
Any other [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2The using enum declaration[enum.udecl]") names the set of declarations found by
type-only lookup ([[basic.lookup.general]](basic.lookup.general "6.5.1General"))
for the [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2The using enum declaration[enum.udecl]") ([[basic.lookup.unqual]](basic.lookup.unqual "6.5.3Unqualified name lookup"), [[basic.lookup.qual]](basic.lookup.qual "6.5.5Qualified name lookup"))[.](#1.sentence-2)
The [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2The using enum declaration[enum.udecl]") shall designate a non-dependent type
with a reachable [*enum-specifier*](dcl.enum#nt:enum-specifier "9.8.1Enumeration declarations[dcl.enum]")[.](#1.sentence-3)
[*Example [1](#example-1)*: enum E { x };void f() {int E; using enum E; // OK}using F = E;using enum F; // OKtemplate<class T> using EE = T;void g() {using enum EE<E>; // OK} — *end example*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8145)
A [*using-enum-declaration*](#nt:using-enum-declaration "9.8.2The using enum declaration[enum.udecl]") is equivalent to a [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]") for each enumerator[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8149)
[*Note [1](#note-1)*:
A [*using-enum-declaration*](#nt:using-enum-declaration "9.8.2The using enum declaration[enum.udecl]") in class scope
makes the enumerators of the named enumeration available via member lookup[.](#3.sentence-1)
[*Example [2](#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](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8168)
[*Note [2](#note-2)*:
Two [*using-enum-declaration*](#nt:using-enum-declaration "9.8.2The using enum declaration[enum.udecl]")*s* that introduce two enumerators of the same name conflict[.](#4.sentence-1)
[*Example [3](#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*]