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 3738
3738
\end {codeblock }
3739
3739
\exitexample
3740
3740
3741
+ \item Otherwise, if \tcode {T} is an enumeration
3742
+ with a fixed underlying type~(\ref {dcl.enum }),
3743
+ the \grammarterm {initializer-list} has a single element \tcode {v}, and
3744
+ the initialization is direct-list-initialization,
3745
+ the object is initialized with the value \tcode {T(v)}~(\ref {expr.type.conv });
3746
+ if a narrowing conversion is required to convert \tcode {v}
3747
+ to the underlying type of \tcode {T}, the program is ill-formed.
3748
+
3749
+ \enterexample
3750
+ \begin {codeblock }
3751
+ enum byte : unsigned char { };
3752
+ byte b { 42 }; // OK
3753
+ byte c = { 42 }; // error
3754
+ byte d = byte{ 42 }; // OK; same value as \tcode {b}
3755
+ byte e { -1 }; // error
3756
+
3757
+ struct A { byte b; };
3758
+ A a1 = { { 42 } }; // error
3759
+ A a2 = { byte{ 42 } }; // OK
3760
+
3761
+ void f(byte);
3762
+ f({ 42 }); // error
3763
+
3764
+ enum class Handle : uint32_t { Invalid = 0 };
3765
+ Handle h { 42 }; // OK
3766
+ \end {codeblock }
3767
+ \exitexample
3768
+
3741
3769
\item Otherwise, if the initializer list has no elements, the object is
3742
3770
value-initialized.
3743
3771
You can’t perform that action at this time.
0 commit comments