Skip to content

Commit a75c7bf

Browse files
burblebeetkoeppe
authored andcommitted
CWG2713 Initialization of reference-to-aggregate from designated initializer list
1 parent b3b0a0b commit a75c7bf

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

source/declarations.tex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5739,7 +5739,8 @@
57395739
\begin{itemize}
57405740
\item
57415741
If the \grammarterm{braced-init-list}
5742-
contains a \grammarterm{designated-initializer-list},
5742+
contains a \grammarterm{designated-initializer-list} and
5743+
\tcode{T} is not a reference type,
57435744
\tcode{T} shall be an aggregate class.
57445745
The ordered \grammarterm{identifier}{s}
57455746
in the \grammarterm{designator}{s}
@@ -5863,7 +5864,9 @@
58635864
\end{example}
58645865

58655866
\item Otherwise, if
5866-
the initializer list has a single element of type \tcode{E} and either
5867+
the initializer list
5868+
is not a \grammarterm{designated-initializer-list} and
5869+
has a single element of type \tcode{E} and either
58675870
\tcode{T} is not a reference type or its referenced type is
58685871
reference-related to \tcode{E}, the object or reference is initialized
58695872
from that element (by copy-initialization for copy-list-initialization,
@@ -5908,6 +5911,9 @@
59085911
struct A { } a;
59095912
struct B { explicit B(const A&); };
59105913
const B& b2{a}; // error: cannot copy-list-initialize \tcode{B} temporary from \tcode{A}
5914+
5915+
struct C { int x; };
5916+
C&& c = { .x = 1 }; // OK
59115917
\end{codeblock}
59125918
\end{example}
59135919

source/overloading.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,8 @@
23562356
expression and special rules apply for converting it to a parameter type.
23572357

23582358
\pnum
2359-
If the initializer list is a \grammarterm{designated-initializer-list},
2359+
If the initializer list is a \grammarterm{designated-initializer-list}
2360+
and the parameter is not a reference,
23602361
a conversion is only possible if
23612362
the parameter has an aggregate type
23622363
that can be initialized from the initializer list

0 commit comments

Comments
 (0)