|
38 | 38 | asm-declaration\br
|
39 | 39 | namespace-alias-definition\br
|
40 | 40 | using-declaration\br
|
| 41 | + using-enum-declaration\br |
41 | 42 | using-directive\br
|
42 | 43 | static_assert-declaration\br
|
43 | 44 | alias-declaration\br
|
|
1418 | 1419 | class-key \opt{attribute-specifier-seq} \opt{nested-name-specifier} identifier\br
|
1419 | 1420 | class-key simple-template-id\br
|
1420 | 1421 | class-key nested-name-specifier \opt{\keyword{template}} simple-template-id\br
|
| 1422 | + elaborated-enum-specifier |
| 1423 | +\end{bnf} |
| 1424 | + |
| 1425 | +\begin{bnf} |
| 1426 | +\nontermdef{elaborated-enum-specifier}\br |
1421 | 1427 | \keyword{enum} \opt{nested-name-specifier} identifier
|
1422 | 1428 | \end{bnf}
|
1423 | 1429 |
|
|
6584 | 6590 | the type of the \grammarterm{id-expression} \tcode{y} is ``\tcode{const volatile double}''.
|
6585 | 6591 | \end{example}
|
6586 | 6592 |
|
6587 |
| -\rSec1[dcl.enum]{Enumeration declarations}% |
| 6593 | +\rSec1[enum]{Enumerations}% |
| 6594 | + |
| 6595 | +\rSec2[dcl.enum]{Enumeration declarations}% |
6588 | 6596 | \indextext{enumeration}%
|
6589 | 6597 | \indextext{\idxcode{\{\}}!enum declaration@\tcode{enum} declaration}%
|
6590 | 6598 | \indextext{\idxcode{enum}!type of}
|
|
6904 | 6912 | \end{codeblock}
|
6905 | 6913 | \end{example}
|
6906 | 6914 |
|
| 6915 | +\rSec2[enum.udecl]{The \tcode{using enum} declaration}% |
| 6916 | +\indextext{enumeration!using declaration}% |
| 6917 | + |
| 6918 | +\begin{bnf} |
| 6919 | +\nontermdef{using-enum-declaration}\br |
| 6920 | + \terminal{using} elaborated-enum-specifier \terminal{;} |
| 6921 | +\end{bnf} |
| 6922 | + |
| 6923 | +\pnum |
| 6924 | +The \grammarterm{elaborated-enum-specifier} |
| 6925 | +shall not name a dependent type |
| 6926 | +and the type shall have a reachable \grammarterm{enum-specifier}. |
| 6927 | + |
| 6928 | +\pnum |
| 6929 | +A \grammarterm{using-enum-declaration} |
| 6930 | +introduces the enumerator names of the named enumeration |
| 6931 | +as if by a \grammarterm{using-declaration} for each enumerator. |
| 6932 | + |
| 6933 | +\pnum |
| 6934 | +\begin{note} |
| 6935 | +A \grammarterm{using-enum-declaration} in class scope |
| 6936 | +adds the enumerators of the named enumeration as members to the scope. |
| 6937 | +This means they are accessible for member lookup. |
| 6938 | +\begin{example} |
| 6939 | +\begin{codeblock} |
| 6940 | +enum class fruit { orange, apple }; |
| 6941 | +struct S { |
| 6942 | + using enum fruit; // OK, introduces \tcode{orange} and \tcode{apple} into \tcode{S} |
| 6943 | +}; |
| 6944 | +void f() { |
| 6945 | + S s; |
| 6946 | + s.orange; // OK, names \tcode{fruit::orange} |
| 6947 | + S::orange; // OK, names \tcode{fruit::orange} |
| 6948 | +} |
| 6949 | +\end{codeblock} |
| 6950 | +\end{example} |
| 6951 | +\end{note} |
| 6952 | + |
| 6953 | +\pnum |
| 6954 | +\begin{note} |
| 6955 | +Two \grammarterm{using-enum-declaration}s |
| 6956 | +that introduce two enumerators of the same name conflict. |
| 6957 | +\begin{example} |
| 6958 | +\begin{codeblock} |
| 6959 | +enum class fruit { orange, apple }; |
| 6960 | +enum class color { red, orange }; |
| 6961 | +void f() { |
| 6962 | + using enum fruit; // OK |
| 6963 | + using enum color; // ill-formed: \tcode{color::orange} and \tcode{fruit::orange} conflict |
| 6964 | +} |
| 6965 | +\end{codeblock} |
| 6966 | +\end{example} |
| 6967 | +\end{note} |
| 6968 | + |
6907 | 6969 | \rSec1[basic.namespace]{Namespaces}%
|
6908 | 6970 | \indextext{namespaces|(}
|
6909 | 6971 |
|
|
7319 | 7381 | \end{codeblock}
|
7320 | 7382 | \end{example}
|
7321 | 7383 |
|
7322 |
| -\rSec2[namespace.udir]{Using directive}% |
| 7384 | +\rSec2[namespace.udir]{Using namespace directive}% |
7323 | 7385 | \indextext{using-directive|(}
|
7324 | 7386 |
|
7325 | 7387 | \begin{bnf}
|
|
7599 | 7661 | \pnum
|
7600 | 7662 | In a \grammarterm{using-declaration} used as a
|
7601 | 7663 | \grammarterm{member-declaration},
|
7602 |
| -each \grammarterm{using-declarator}{'s} \grammarterm{nested-name-specifier} |
7603 |
| -shall name a base class of the class being defined. If a |
| 7664 | +each \grammarterm{using-declarator} |
| 7665 | +shall either name an enumerator |
| 7666 | +or have a \grammarterm{nested-name-specifier} |
| 7667 | +naming a base class of the class being defined. |
| 7668 | +\begin{example} |
| 7669 | +\begin{codeblock} |
| 7670 | +enum class button { up, down }; |
| 7671 | +struct S { |
| 7672 | + using button::up; |
| 7673 | + button b = up; // OK |
| 7674 | +}; |
| 7675 | +\end{codeblock} |
| 7676 | +\end{example} |
| 7677 | +If a |
7604 | 7678 | \grammarterm{using-declarator} names a constructor, its
|
7605 | 7679 | \grammarterm{nested-name-specifier} shall name a direct base class of the class
|
7606 | 7680 | being defined.
|
|
7667 | 7741 | A \grammarterm{using-declaration} shall not name a namespace.
|
7668 | 7742 |
|
7669 | 7743 | \pnum
|
7670 |
| -A \grammarterm{using-declaration} shall not name a scoped enumerator. |
7671 |
| - |
7672 |
| -\pnum |
7673 |
| -A \grammarterm{using-declaration} that names a class member shall be a |
| 7744 | +A \grammarterm{using-declaration} that names a class member |
| 7745 | +other than an enumerator |
| 7746 | +shall be a |
7674 | 7747 | \grammarterm{member-declaration}.
|
7675 | 7748 | \begin{example}
|
7676 | 7749 | \begin{codeblock}
|
|
0 commit comments