Skip to content

Commit 897071a

Browse files
committed
Merge 2016-02 CWG Motion 11
2 parents c8c8a17 + 34eb474 commit 897071a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

source/declarators.tex

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3778,6 +3778,34 @@
37783778
\end{codeblock}
37793779
\exitexample
37803780

3781+
\item Otherwise, if \tcode{T} is an enumeration
3782+
with a fixed underlying type~(\ref{dcl.enum}),
3783+
the \grammarterm{initializer-list} has a single element \tcode{v}, and
3784+
the initialization is direct-list-initialization,
3785+
the object is initialized with the value \tcode{T(v)}~(\ref{expr.type.conv});
3786+
if a narrowing conversion is required to convert \tcode{v}
3787+
to the underlying type of \tcode{T}, the program is ill-formed.
3788+
3789+
\enterexample
3790+
\begin{codeblock}
3791+
enum byte : unsigned char { };
3792+
byte b { 42 }; // OK
3793+
byte c = { 42 }; // error
3794+
byte d = byte{ 42 }; // OK; same value as \tcode{b}
3795+
byte e { -1 }; // error
3796+
3797+
struct A { byte b; };
3798+
A a1 = { { 42 } }; // error
3799+
A a2 = { byte{ 42 } }; // OK
3800+
3801+
void f(byte);
3802+
f({ 42 }); // error
3803+
3804+
enum class Handle : uint32_t { Invalid = 0 };
3805+
Handle h { 42 }; // OK
3806+
\end{codeblock}
3807+
\exitexample
3808+
37813809
\item Otherwise, if the initializer list has no elements, the object is
37823810
value-initialized.
37833811

0 commit comments

Comments
 (0)