Skip to content

Commit dbbeeba

Browse files
committed
P3920R0 Wording for NB comment resolution on trivial relocation
Also fixes NB BDS 2-034, CA-133, CA-136, CA-137, CN 6.9.1p9, FR 002-025, US 9-024, US 10-023, US 44-082, US 45-081, US 46-085, US 47-084, and US 73-131 (C++26 CD).
1 parent 2ab6288 commit dbbeeba

File tree

10 files changed

+17
-323
lines changed

10 files changed

+17
-323
lines changed

source/basic.tex

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,15 +5230,6 @@
52305230
Scalar types, trivially copyable class types\iref{class.prop},
52315231
arrays of such types, and cv-qualified versions of these
52325232
types are collectively called \defnadjx{trivially copyable}{types}{type}.
5233-
\label{term.trivially.relocatable.type}%
5234-
Scalar types, trivially relocatable class types\iref{class.prop},
5235-
arrays of such types, and cv-qualified versions of these
5236-
types are collectively called \defnadjx{trivially relocatable}{types}{type}.
5237-
\label{term.replaceable.type}%
5238-
\indextext{replaceable!type|see{type, replaceable}}%
5239-
Cv-unqualified scalar types, replaceable class types\iref{class.prop}, and
5240-
arrays of such types are collectively called
5241-
\defnx{replaceable types}{type!replaceable}.
52425233
\label{term.standard.layout.type}%
52435234
Scalar types, standard-layout class
52445235
types\iref{class.prop}, arrays of such types, and

source/classes.tex

Lines changed: 4 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252

5353
\begin{bnf}
5454
\nontermdef{class-property-specifier}\br
55-
\keyword{final}\br
56-
\keyword{trivially_relocatable_if_eligible}\br
57-
\keyword{replaceable_if_eligible}
55+
\keyword{final}
5856
\end{bnf}
5957

6058
\begin{bnf}
@@ -131,8 +129,7 @@
131129
within a single \grammarterm{class-property-specifier-seq}.
132130
Whenever a \grammarterm{class-key} is followed
133131
by a \grammarterm{class-head-name},
134-
one of the identifiers \tcode{final}, \tcode{trivially_relocatable_if_eligible},
135-
or \tcode{replaceable_if_eligible}, and a colon or left brace,
132+
the identifier \tcode{final}, and a colon or left brace,
136133
the identifier is interpreted as a \grammarterm{class-property-specifier}.
137134
\begin{example}
138135
\begin{codeblock}
@@ -142,10 +139,8 @@
142139

143140
struct X {
144141
struct C { constexpr operator int() { return 5; } };
145-
struct B trivially_relocatable_if_eligible : C{};
146-
// OK, definition of nested class \tcode{B},
147-
// not declaration of a bit-field member
148-
// \tcode{trivially_relocatable_if_eligible}
142+
struct B final : C{}; // OK, definition of nested class \tcode{B},
143+
// not declaration of a bit-field member \tcode{final}
149144
};
150145
\end{codeblock}
151146
\end{example}
@@ -187,88 +182,6 @@
187182
\item that has a trivial, non-deleted destructor\iref{class.dtor}.
188183
\end{itemize}
189184

190-
\pnum
191-
A class \tcode{C} is \defn{default-movable} if
192-
193-
\begin{itemize}
194-
\item overload resolution for direct-initializing an object of type \tcode{C}
195-
from an xvalue of type \tcode{C} selects a constructor that is a direct member
196-
of \tcode{C} and is neither user-provided nor deleted,
197-
198-
\item overload resolution for assigning to an lvalue of type \tcode{C} from an
199-
xvalue of type \tcode{C} selects an assignment operator function that is a
200-
direct member of \tcode{C} and is neither user-provided nor deleted, and
201-
202-
\item \tcode{C} has a destructor that is neither user-provided nor deleted.
203-
\end{itemize}
204-
205-
\pnum
206-
A class is \defn{eligible for trivial relocation} unless it
207-
\begin{itemize}
208-
\item has any virtual base classes,
209-
\item has a base class that is not a trivially relocatable class,
210-
\item has a non-static data member of an object type that is not of a
211-
trivially relocatable type, or
212-
213-
\item has a deleted destructor,
214-
\end{itemize}
215-
except that it is \impldef{whether an otherwise-eligible union having one or
216-
more subobjects of polymorphic class type is eligible for trivial relocation}
217-
whether an otherwise-eligible union having one or more subobjects of
218-
polymorphic class type is eligible for trivial relocation.
219-
220-
\pnum
221-
A class \tcode{C} is a \defnadj{trivially relocatable}{class}
222-
if it is eligible for trivial relocation and
223-
\begin{itemize}
224-
\item has the \tcode{trivially_relocatable_if_eligible} \grammarterm{class-property-specifier},
225-
\item is a union with no user-declared special member functions, or
226-
\item is default-movable.
227-
\end{itemize}
228-
229-
\pnum
230-
\begin{note}
231-
A class with const-qualified or reference non-static data members can be
232-
trivially relocatable.
233-
\end{note}
234-
235-
\pnum
236-
A class \tcode{C} is \defn{eligible for replacement} unless
237-
\begin{itemize}
238-
\item it has a base class that is not a replaceable class,
239-
\item it has a non-static data member that is not of a replaceable type,
240-
\item overload resolution fails or selects a deleted constructor when
241-
direct-initializing an object of type \tcode{C} from an xvalue of type
242-
\tcode{C}\iref{dcl.init.general},
243-
244-
\item overload resolution fails or selects a deleted assignment operator
245-
function when assigning to an lvalue of type \tcode{C} from an xvalue of type
246-
\tcode{C}\iref{expr.assign,over.assign}, or
247-
248-
\item it has a deleted destructor.
249-
\end{itemize}
250-
251-
\indextext{replaceable!class|see{class, replaceable}}%
252-
\pnum
253-
A class \tcode{C} is a \defnx{replaceable class}{class!replaceable} if it is
254-
eligible for replacement and
255-
\begin{itemize}
256-
\item has the \tcode{replaceable_if_eligible} \grammarterm{class-property-specifier},
257-
\item is a union with no user-declared special member functions, or
258-
\item is default-movable.
259-
\end{itemize}
260-
261-
\pnum
262-
\begin{note}
263-
Accessibility of the special member functions is not considered when
264-
establishing trivial relocatability or replaceability.
265-
\end{note}
266-
267-
\pnum
268-
\begin{note}
269-
Not all trivially copyable classes are trivially relocatable or replaceable.
270-
\end{note}
271-
272185
\pnum
273186
A class \tcode{S} is a \defnadj{standard-layout}{class} if it:
274187
\begin{itemize}

source/compatibility.tex

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,6 @@
107107

108108
\rSec2[diff.cpp23.dcl.dcl]{\ref{dcl}: declarations}
109109

110-
\diffref{dcl.decl.general}
111-
\change
112-
Introduction of \tcode{trivially_relocatable_if_eligible} and
113-
\tcode{replaceable_if_eligible} as identifiers with special meaning\iref{lex.name}.
114-
\rationale
115-
Support declaration of trivially relocatable and replaceable types\iref{class.prop}.
116-
\effect
117-
Valid \CppXXIII{} code can become ill-formed.
118-
\begin{example}
119-
\begin{codeblock}
120-
struct C {};
121-
struct C replaceable_if_eligible {}; // was well-formed (new variable \tcode{replaceable_if_eligible})
122-
// now ill-formed (redefines \tcode{C})
123-
\end{codeblock}
124-
\end{example}
125-
126110
\diffref{dcl.init.list}
127111
\change
128112
Pointer comparisons between \tcode{initializer_list} objects' backing arrays
@@ -262,17 +246,6 @@
262246
Valid \CppXXIII{} code that \tcode{\#include}{s} headers with these names may be
263247
invalid in this revision of \Cpp{}.
264248

265-
\diffref{res.on.macro.definitions}
266-
\change
267-
Additional restrictions on macro names.
268-
\rationale
269-
Avoid hard to diagnose or non-portable constructs.
270-
\effect
271-
Names of special identifiers may not be used as macro names.
272-
Valid \CppXXIII{} code that defines \tcode{replaceable_if_eligible} or
273-
\tcode{trivially_relocatable_if_eligible} as macros is invalid
274-
in this revision of \Cpp{}.
275-
276249
\rSec2[diff.cpp23.mem]{\ref{mem}: memory management library}
277250

278251
\diffref{c.malloc}

source/expressions.tex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,9 +2231,7 @@
22312231
other than by changing:
22322232
\begin{itemize}
22332233
\item the size and/or alignment of the closure type,
2234-
\item whether the closure type is trivially copyable\iref{class.prop},
2235-
\item whether the closure type is trivially relocatable\iref{class.prop},
2236-
\item whether the closure type is replaceable\iref{class.prop}, or
2234+
\item whether the closure type is trivially copyable\iref{class.prop}, or
22372235
\item whether the closure type is a standard-layout class\iref{class.prop}.
22382236
\end{itemize}
22392237

source/lex.tex

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,6 @@
966966
\indextext{\idxcode{final}}%
967967
\indextext{\idxcode{module}}%
968968
\indextext{\idxcode{override}}%
969-
\indextext{\idxcode{replaceable_if_eligible}}%
970-
\indextext{\idxcode{trivially_relocatable_if_eligible}}%
971969
The identifiers in \tref{lex.name.special} have a special meaning when
972970
appearing in a certain context. When referred to in the grammar, these identifiers
973971
are used explicitly rather than using the \grammarterm{identifier} grammar production.
@@ -976,15 +974,18 @@
976974
token as a regular \grammarterm{identifier}.
977975

978976
\begin{multicolfloattable}{Identifiers with special meaning}{lex.name.special}
979-
{llll}
980-
\keyword{final} \\
981-
\keyword{override} \\\columnbreak
982-
\keyword{import} \\
983-
\keyword{module} \\\columnbreak
984-
\keyword{post} \\
985-
\keyword{pre} \\\columnbreak
986-
\keyword{replaceable_if_eligible} \\
987-
\keyword{trivially_relocatable_if_eligible} \\
977+
{llllll}
978+
\keyword{final} \\
979+
\columnbreak
980+
\keyword{import} \\
981+
\columnbreak
982+
\keyword{module} \\
983+
\columnbreak
984+
\keyword{override} \\
985+
\columnbreak
986+
\keyword{post} \\
987+
\columnbreak
988+
\keyword{pre} \\
988989
\end{multicolfloattable}
989990

990991
\pnum

source/lib-intro.tex

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,20 +3850,6 @@
38503850
\ref{depr} is a trivially copyable class, a standard-layout class, or an
38513851
implicit-lifetime class\iref{class.prop}.
38523852

3853-
\pnum
3854-
Unless explicitly stated otherwise, it is unspecified whether any class for
3855-
which trivial relocation (i.e., the effects of
3856-
\tcode{trivially_relocate}\iref{obj.lifetime}) would be semantically equivalent
3857-
to move-construction of the destination object followed by destruction of the
3858-
source object is a trivially relocatable class\iref{class.prop}.
3859-
3860-
\pnum
3861-
Unless explicitly stated otherwise, it is unspecified whether a class \tcode{C}
3862-
is a replaceable class\iref{class.prop} if assigning an xvalue \tcode{a} of
3863-
type \tcode{C} to an object \tcode{b} of type \tcode{C} is semantically
3864-
equivalent to destroying \tcode{b} and then constructing from \tcode{a} in
3865-
\tcode{b}'s place.
3866-
38673853
\rSec3[protection.within.classes]{Protection within classes}
38683854

38693855
\pnum

source/memory.tex

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@
105105
template<class T>
106106
const volatile T* start_lifetime_as_array(const volatile void* p, // freestanding
107107
size_t n) noexcept;
108-
template<class T>
109-
T* trivially_relocate(T* first, T* last, T* result); // freestanding
110-
template<class T>
111-
constexpr T* relocate(T* first, T* last, T* result); // freestanding
112108

113109
// \ref{allocator.tag}, allocator argument tag
114110
struct allocator_arg_t { explicit allocator_arg_t() = default; }; // freestanding
@@ -1135,128 +1131,6 @@
11351131
a pointer that compares equal to \tcode{p}\iref{expr.eq}.
11361132
\end{itemdescr}
11371133

1138-
\indexlibraryglobal{trivially_relocate}%
1139-
\begin{itemdecl}
1140-
template<class T>
1141-
T* trivially_relocate(T* first, T* last, T* result);
1142-
\end{itemdecl}
1143-
1144-
\begin{itemdescr}
1145-
\pnum
1146-
\mandates
1147-
\tcode{is_trivially_relocatable_v<T> \&\& !is_const_v<T>} is \tcode{true}.
1148-
\tcode{T} is not an array of unknown bound.
1149-
1150-
\pnum
1151-
\expects
1152-
\begin{itemize}
1153-
\item
1154-
\range{first}{last} is a valid range.
1155-
\item
1156-
\range{result}{result + (last - first)} denotes a region of storage that
1157-
is a subset of the region reachable through \tcode{result}\iref{basic.compound}
1158-
and suitably aligned for the type \tcode{T}.
1159-
\item
1160-
No element in the range \range{first}{last} is a potentially-overlapping subobject.
1161-
\end{itemize}
1162-
1163-
\pnum
1164-
\ensures
1165-
No effect if \tcode{result == first} is \tcode{true}.
1166-
Otherwise, the range denoted by \range{result}{result + (last - first)}
1167-
contains objects (including subobjects) whose lifetime has begun and whose
1168-
object representations are the original object representations of the
1169-
corresponding objects in the source range \range{first}{last} except
1170-
for any parts of the object representations used by the implementation to
1171-
represent type information\iref{intro.object}. If any of the objects has
1172-
union type, its active member is the same as that of the corresponding object
1173-
in the source range. If any of the aforementioned objects has a non-static
1174-
data member of reference type, that reference refers to the same entity as
1175-
does the corresponding reference in the source range. The lifetimes of the
1176-
original objects in the source range have ended.
1177-
1178-
\pnum
1179-
\returns
1180-
\tcode{result + (last - first)}.
1181-
1182-
\pnum
1183-
\throws
1184-
Nothing.
1185-
1186-
\pnum
1187-
\complexity
1188-
Linear in the length of the source range.
1189-
1190-
\pnum
1191-
\remarks
1192-
The destination region of storage is considered reused\iref{basic.life}.
1193-
No constructors or destructors are invoked.
1194-
1195-
\begin{note}
1196-
Overlapping ranges are supported.
1197-
\end{note}
1198-
\end{itemdescr}
1199-
1200-
\indexlibraryglobal{relocate}%
1201-
\begin{itemdecl}
1202-
template<class T>
1203-
constexpr T* relocate(T* first, T* last, T* result);
1204-
\end{itemdecl}
1205-
1206-
\begin{itemdescr}
1207-
\pnum
1208-
\mandates
1209-
\tcode{is_nothrow_relocatable_v<T> \&\& !is_const_v<T>} is \tcode{true}.
1210-
\tcode{T} is not an array of unknown bound.
1211-
1212-
\pnum
1213-
\expects
1214-
\begin{itemize}
1215-
\item
1216-
\range{first}{last} is a valid range.
1217-
\item
1218-
\range{result}{result + (last - first)} denotes a region of storage that is
1219-
a subset of the region reachable through \tcode{result}\iref{basic.compound}
1220-
and suitably aligned for the type \tcode{T}.
1221-
\item
1222-
No element in the range \range{first}{last} is a potentially-overlapping
1223-
subobject.
1224-
\end{itemize}
1225-
1226-
\pnum
1227-
\effects
1228-
\begin{itemize}
1229-
\item
1230-
If \tcode{result == first} is \tcode{true}, no effect;
1231-
\item
1232-
otherwise, if not called during constant evaluation and
1233-
\tcode{is_trivially_relocatable_v<T>} is \tcode{true}, then has
1234-
effects equivalent to: \tcode{trivially_relocate(first, last, result);}
1235-
\item
1236-
otherwise, for each integer \tcode{i} in \range{0}{last - first},
1237-
\begin{itemize}
1238-
\item
1239-
if \tcode{T} is an array type, equivalent to:
1240-
\tcode{relocate(begin(first[i]), end(first[i]), *start_lifetime_as<T>(result + i));}
1241-
\item
1242-
otherwise, equivalent to:
1243-
\tcode{construct_at(result + i, std::move(first[i])); destroy_at(first + i);}
1244-
\end{itemize}
1245-
\end{itemize}
1246-
1247-
\pnum
1248-
\returns
1249-
\tcode{result + (last - first)}.
1250-
1251-
\pnum
1252-
\throws
1253-
Nothing.
1254-
1255-
\begin{note}
1256-
Overlapping ranges are supported.
1257-
\end{note}
1258-
\end{itemdescr}
1259-
12601134
\rSec2[allocator.tag]{Allocator argument tag}
12611135

12621136
\indexlibraryglobal{allocator_arg_t}%

0 commit comments

Comments
 (0)