64 lines
4.1 KiB
Markdown
64 lines
4.1 KiB
Markdown
[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.2 The using enum declaration [enum.udecl]")
|
||
using enum [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2 The using enum declaration [enum.udecl]") ;
|
||
|
||
[using-enum-declarator:](#nt:using-enum-declarator "9.8.2 The using enum declaration [enum.udecl]")
|
||
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]")opt [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")
|
||
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]")opt [*simple-template-id*](temp.names#nt:simple-template-id "13.3 Names of template specializations [temp.names]")
|
||
[*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9 Type 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.2 The using enum declaration [enum.udecl]") of
|
||
the form [*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9 Type splicing [dcl.type.splice]") designates the same type designated by the [*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9 Type splicing [dcl.type.splice]")[.](#1.sentence-1)
|
||
|
||
Any other [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2 The using enum declaration [enum.udecl]") names the set of declarations found by
|
||
type-only lookup ([[basic.lookup.general]](basic.lookup.general "6.5.1 General"))
|
||
for the [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2 The using enum declaration [enum.udecl]") ([[basic.lookup.unqual]](basic.lookup.unqual "6.5.3 Unqualified name lookup"), [[basic.lookup.qual]](basic.lookup.qual "6.5.5 Qualified name lookup"))[.](#1.sentence-2)
|
||
|
||
The [*using-enum-declarator*](#nt:using-enum-declarator "9.8.2 The using enum declaration [enum.udecl]") shall designate a non-dependent type
|
||
with a reachable [*enum-specifier*](dcl.enum#nt:enum-specifier "9.8.1 Enumeration 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.2 The using enum declaration [enum.udecl]") is equivalent to a [*using-declaration*](namespace.udecl#nt:using-declaration "9.10 The 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.2 The 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.2 The 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*]
|