Skip to content

Commit

Permalink
NB RU-1 (C++17 CD) Why must empty or fully-initialized const objects …
Browse files Browse the repository at this point in the history
…be initialized?

Also fixes CWG 253.
  • Loading branch information
zygoloid authored and tkoeppe committed Nov 25, 2016
1 parent c6b8ac3 commit c6a9363
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion source/declarators.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2594,8 +2594,31 @@
no initialization is performed.
\end{itemize}

A class type \tcode{T} is \defn{const-default-constructible} if
default-initialization of \tcode{T} would invoke
a user-provided constructor of \tcode{T} (not inherited from a base class)
or if

\begin{itemize}
\item
each direct non-variant non-static data member \tcode{M} of \tcode{T}
has a default member initializer
or, if \tcode{M} is of class type \tcode{X} (or array thereof),
\tcode{X} is const-default-constructible,
\item
if \tcode{T} is a union with at least one non-static data member,
exactly one variant member has a default member initializer,
\item
if \tcode{T} is a not a union,
for each anonymous union member with at least one non-static data member (if any),
exactly one non-static data member has a default member initializer, and
\item
each potentially constructed base class of \tcode{T} is const-default-constructible.
\end{itemize}

If a program calls for the default-initialization of an object of a
const-qualified type \tcode{T}, \tcode{T} shall be a class type with a user-provided default constructor.
const-qualified type \tcode{T},
\tcode{T} shall be a const-default-constructible class type or array thereof.

\pnum
\indextext{value-initialization}%
Expand Down

0 comments on commit c6a9363

Please sign in to comment.