File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 3778
3778
\end {codeblock }
3779
3779
\exitexample
3780
3780
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
+
3781
3809
\item Otherwise, if the initializer list has no elements, the object is
3782
3810
value-initialized.
3783
3811
You can’t perform that action at this time.
0 commit comments