From Jason Turner

[enum.udecl]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpsbxb45u5/{from.md → to.md} +57 -0
tmp/tmpsbxb45u5/{from.md → to.md} RENAMED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### The `using enum` declaration <a id="enum.udecl">[[enum.udecl]]</a>
2
+
3
+ ``` bnf
4
+ using-enum-declaration:
5
+ 'using' elaborated-enum-specifier ';'
6
+ ```
7
+
8
+ The *elaborated-enum-specifier* shall not name a dependent type and the
9
+ type shall have a reachable *enum-specifier*.
10
+
11
+ A *using-enum-declaration* introduces the enumerator names of the named
12
+ enumeration as if by a *using-declaration* for each enumerator.
13
+
14
+ [*Note 1*:
15
+
16
+ A *using-enum-declaration* in class scope adds the enumerators of the
17
+ named enumeration as members to the scope. This means they are
18
+ accessible for member lookup.
19
+
20
+ [*Example 1*:
21
+
22
+ ``` cpp
23
+ enum class fruit { orange, apple };
24
+ struct S {
25
+ using enum fruit; // OK, introduces orange and apple into S
26
+ };
27
+ void f() {
28
+ S s;
29
+ s.orange; // OK, names fruit::orange
30
+ S::orange; // OK, names fruit::orange
31
+ }
32
+ ```
33
+
34
+ — *end example*]
35
+
36
+ — *end note*]
37
+
38
+ [*Note 2*:
39
+
40
+ Two *using-enum-declaration*s that introduce two enumerators of the same
41
+ name conflict.
42
+
43
+ [*Example 2*:
44
+
45
+ ``` cpp
46
+ enum class fruit { orange, apple };
47
+ enum class color { red, orange };
48
+ void f() {
49
+ using enum fruit; // OK
50
+ using enum color; // error: color::orange and fruit::orange conflict
51
+ }
52
+ ```
53
+
54
+ — *end example*]
55
+
56
+ — *end note*]
57
+