Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3671,23 +3671,68 @@
the address of an unspecified byte of storage
occupied by the complete object of that subobject.

\pnum
A \defn{union elemental subobject} is
a direct member of a union or
an element of an array that is a union elemental subobject.
An \defnadj{inactive}{union elemental subobject} is
a union elemental subobject that is not within its lifetime.

\pnum
The \defnx{constituent values}{constituent value} of an object $o$ are
\begin{itemize}
\item
if $o$ has scalar type, the value of $o$;
\item
otherwise, the constituent values of any direct subobjects of $o$
other than inactive union members.
other than inactive union elemental subobjects.
\end{itemize}
The \defnx{constituent references}{constituent reference} of an object $o$ are
\begin{itemize}
\item
any direct members of $o$ that have reference type, and
\item
the constituent references of any direct subobjects of $o$
other than inactive union members.
other than inactive union elemental subobjects.
\end{itemize}
\begin{example}
\begin{codeblock}
struct A {
struct X {
int i;
int j;
};

struct Y {
X x1;
X x2;
};

union {
int i;
int arr[4];
Y y;
};
};

constexpr A v1; // OK, no constituent values
constexpr A v2{.i=1}; // OK, the constituent values are \tcode{\{v2.i\}}
constexpr A v3 = []{
A a;
std::start_lifetime(a.arr); // OK, arr is now the active element of the union
new (&a.arr[1]) int(1);
a.arr[2] = 2;
return a;
}(); // OK, the constituent values are \tcode{\{v3.arr[1], v3.arr[2]\}}
constexpr A v4 = []{
A a;
a.y.x1.i = 1;
a.y.x2.j = 2;
return a;
}(); // error: the constituent values include \tcode{v4.y.x1.j} and \tcode{v4.y.x2.i}
// which have erroneous value
\end{codeblock}
\end{example}

\pnum
Some operations are described as
Expand Down
13 changes: 1 addition & 12 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1332,18 +1332,7 @@
\defnx{non-trivial}{constructor!default!non-trivial}.

\pnum
If a default constructor of a union-like class \tcode{X} is trivial,
then for each union \tcode{U}
that is either \tcode{X} or an anonymous union member of \tcode{X},
if the first variant member, if any, of \tcode{U}
has implicit-lifetime type\iref{basic.types.general},
the default constructor of \tcode{X} begins the lifetime of that member
if it is not the active member of its union.
\begin{note}
It is already the active member if \tcode{U} was value-initialized.
\end{note}
Otherwise,
an implicitly-defined\iref{dcl.fct.def.default} default constructor performs the set of
An implicitly-defined\iref{dcl.fct.def.default} default constructor performs the set of
initializations of the class that would be performed by a user-written default
constructor for that class with no
\grammarterm{ctor-initializer}\iref{class.base.init} and an empty
Expand Down
27 changes: 27 additions & 0 deletions source/memory.tex
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
bool is_sufficiently_aligned(T* ptr); // freestanding

// \ref{obj.lifetime}, explicit lifetime management
template<class T>
constexpr void start_lifetime(T& r) noexcept; // freestanding
template<class T>
T* start_lifetime_as(void* p) noexcept; // freestanding
template<class T>
Expand Down Expand Up @@ -1036,6 +1038,31 @@

\rSec2[obj.lifetime]{Explicit lifetime management}

\indexlibraryglobal{start_lifetime}%
\begin{itemdecl}
template<class T>
constexpr void start_lifetime(T& r) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\mandates
\tcode{T} is a complete type and
an implicit-lifetime\iref{basic.types} aggregate\iref{dcl.init.aggr}.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing final "type".

Copy link
Copy Markdown
Member Author

@eisenwave eisenwave Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intentionally removed by fixup commit. The defined term is just "aggregate", not "aggregate type", though this continues to surprise people.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.


\pnum
\effects
If the object referenced by \tcode{r}
is already within its lifetime\iref{basic.life},
no effects.
Otherwise, begins the lifetime of the object referenced by \tcode{r}.
\begin{note}
No initialization is performed and no subobject has its lifetime started.
If \tcode{r} denotes a member of a union $U$,
it becomes the active member of $U$\iref{class.union}.
\end{note}
\end{itemdescr}

\indexlibraryglobal{start_lifetime_as}%
\begin{itemdecl}
template<class T>
Expand Down
2 changes: 1 addition & 1 deletion source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@
\defnxname{cpp_template_parameters} & \tcode{202502L} \\ \rowsep
\defnxname{cpp_template_template_args} & \tcode{201611L} \\ \rowsep
\defnxname{cpp_threadsafe_static_init} & \tcode{200806L} \\ \rowsep
\defnxname{cpp_trivial_union} & \tcode{202502L} \\ \rowsep
\defnxname{cpp_trivial_union} & \tcode{202603L} \\ \rowsep
\defnxname{cpp_unicode_characters} & \tcode{200704L} \\ \rowsep
\defnxname{cpp_unicode_literals} & \tcode{200710L} \\ \rowsep
\defnxname{cpp_user_defined_literals} & \tcode{200809L} \\ \rowsep
Expand Down
1 change: 1 addition & 0 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@
#define @\defnlibxname{cpp_lib_ssize}@ 201902L // freestanding, also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_sstream_from_string_view}@ 202306L // also in \libheader{sstream}
#define @\defnlibxname{cpp_lib_stacktrace}@ 202011L // also in \libheader{stacktrace}
#define @\defnlibxname{cpp_lib_start_lifetime}@ 202603L // freestanding, also in \libheader{memory}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"freestanding" is not in the paper?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but it's in the synopsis. We can mention it as an editorial fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in a fixup commit right now. Maybe it deserves a proper message.

#define @\defnlibxname{cpp_lib_start_lifetime_as}@ 202207L // freestanding, also in \libheader{memory}
#define @\defnlibxname{cpp_lib_starts_ends_with}@ 201711L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_stdatomic_h}@ 202011L // also in \libheader{stdatomic.h}
Expand Down
4 changes: 3 additions & 1 deletion source/templates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2573,7 +2573,9 @@
they are of reference type and they refer to the same object or function, or

\item
they are of array type and their corresponding elements are template-argument-equivalent,
they are of array type and their corresponding elements are either
both within their lifetimes and template-argument-equivalent or
both not within their lifetimes,
\begin{footnote}
An array as a \grammarterm{template-parameter} decays to a pointer.
\end{footnote}
Expand Down
Loading