Skip to content

Commit 9eb37be

Browse files
authored
Merge 2024-11 CWG Motion 5
P3247R2 Deprecate the notion of trivial types
2 parents 573f15d + a2d0ec7 commit 9eb37be

File tree

7 files changed

+56
-40
lines changed

7 files changed

+56
-40
lines changed

source/basic.tex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4959,11 +4959,6 @@
49594959
Scalar types, trivially copyable class types\iref{class.prop},
49604960
arrays of such types, and cv-qualified versions of these
49614961
types are collectively called \defnadjx{trivially copyable}{types}{type}.
4962-
\label{term.trivial.type}%
4963-
Scalar types, trivial class types\iref{class.prop},
4964-
arrays of such types, and cv-qualified versions of these
4965-
types are collectively called
4966-
\defnadjx{trivial}{types}{type}.
49674962
\label{term.standard.layout.type}%
49684963
Scalar types, standard-layout class
49694964
types\iref{class.prop}, arrays of such types, and

source/classes.tex

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@
172172
\item that has a trivial, non-deleted destructor\iref{class.dtor}.
173173
\end{itemize}
174174

175-
\pnum
176-
A \defnadj{trivial}{class} is a class that is trivially copyable and
177-
has one or more eligible default constructors\iref{class.default.ctor},
178-
all of which are trivial.
179-
\begin{note}
180-
In particular, a trivially copyable or trivial class does not have
181-
virtual functions or virtual base classes.
182-
\end{note}
183-
184175
\pnum
185176
A class \tcode{S} is a \defnadj{standard-layout}{class} if it:
186177
\begin{itemize}
@@ -272,25 +263,25 @@
272263
\pnum
273264
\begin{example}
274265
\begin{codeblock}
275-
struct N { // neither trivial nor standard-layout
266+
struct N { // neither trivially copyable nor standard-layout
276267
int i;
277268
int j;
278269
virtual ~N();
279270
};
280271

281-
struct T { // trivial but not standard-layout
272+
struct T { // trivially copyable but not standard-layout
282273
int i;
283274
private:
284275
int j;
285276
};
286277

287-
struct SL { // standard-layout but not trivial
278+
struct SL { // standard-layout but not trivially copyable
288279
int i;
289280
int j;
290281
~SL();
291282
};
292283

293-
struct POD { // both trivial and standard-layout
284+
struct POD { // both trivially copyable and standard-layout
294285
int i;
295286
int j;
296287
};
@@ -5941,7 +5932,7 @@
59415932
B bobj; // definition of \tcode{bobj}
59425933

59435934
extern X xobj;
5944-
int* p3 = &xobj.i; // OK, \tcode{X} is a trivial class
5935+
int* p3 = &xobj.i; // OK, all constructors of \tcode{X} are trivial
59455936
X xobj;
59465937
\end{codeblock}
59475938
For another example,

source/containers.tex

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9536,8 +9536,9 @@
95369536

95379537
\pnum
95389538
For any $\tcode{N} > 0$,
9539-
if \tcode{is_trivial_v<T>} is \tcode{false}, then
9540-
no \tcode{inplace_vector<T, N>} member functions
9539+
if \tcode{T} is not trivially copyable or
9540+
\tcode{is_trivially_default_constructible_v<T>} is \tcode{false},
9541+
then no \tcode{inplace_vector<T, N>} member functions
95419542
are usable in constant expressions.
95429543

95439544
\pnum
@@ -20617,13 +20618,13 @@
2061720618
\end{codeblock}
2061820619

2061920620
\pnum
20620-
Each of \tcode{layout_left}, \tcode{layout_right}, and \tcode{layout_stride}
20621-
meets the layout mapping policy requirements and is a trivial type.
20622-
20623-
\pnum
20624-
Each specialization of
20625-
\tcode{layout_left_padded} and \tcode{layout_right_padded}
20626-
meets the layout mapping policy requirements and is a trivial type.
20621+
Each of \tcode{layout_left}, \tcode{layout_right}, and \tcode{layout_stride},
20622+
as well as each specialization of
20623+
\tcode{layout_left_padded} and \tcode{layout_right_padded},
20624+
meets the layout mapping policy requirements and is a trivially copyable type.
20625+
Furthermore,
20626+
\tcode{is_trivially_default_constructible_v<T>} is \tcode{true}
20627+
for any such type \tcode{T}.
2062720628

2062820629
\rSec4[mdspan.layout.left]{Class template \tcode{layout_left::mapping}}
2062920630

source/future.tex

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@
286286

287287
\begin{codeblock}
288288
namespace std {
289+
template<class T> struct is_trivial;
290+
template<class T> constexpr bool is_trivial_v = is_trivial<T>::value;
289291
template<class T> struct is_pod;
290292
template<class T> constexpr bool is_pod_v = is_pod<T>::value;
291293
template<size_t Len, size_t Align = @\exposid{default-alignment}@> // \seebelow
@@ -304,13 +306,48 @@
304306
any of the templates defined in this subclause is undefined,
305307
unless explicitly permitted by the specification of the corresponding template.
306308

309+
\pnum
310+
\label{term.trivial.type}%
311+
A \defnadj{trivial}{class} is a class that is trivially copyable and
312+
has one or more eligible default constructors, all of which are trivial.
313+
\begin{note}
314+
In particular,
315+
a trivial class does not have virtual functions or virtual base classes.
316+
\end{note}
317+
A \defnadj{trivial}{type} is a scalar type, a trivial class,
318+
an array of such a type, or a cv-qualified version of one of these types..
319+
307320
\pnum
308321
\indextext{POD}%
309322
A \term{POD class} is a class that is both a trivial class and a
310323
standard-layout class, and has no non-static data members of type non-POD class
311324
(or array thereof). A \term{POD type} is a scalar type, a POD class, an array
312325
of such a type, or a cv-qualified version of one of these types.
313326

327+
\indexlibraryglobal{is_trivial}%
328+
\begin{itemdecl}
329+
template<class T> struct is_trivial;
330+
\end{itemdecl}
331+
332+
\begin{itemdescr}
333+
\pnum
334+
\expects
335+
\tcode{remove_all_extents_t<T>} shall be a complete type or \cv{} \keyword{void}.
336+
337+
\pnum
338+
\remarks
339+
\tcode{is_trivial<T>} is a \oldconcept{UnaryTypeTrait}\iref{meta.rqmts}
340+
with a base characteristic of \tcode{true_type}
341+
if \tcode{T} is a trivial type,
342+
and \tcode{false_type} otherwise.
343+
344+
\pnum
345+
\begin{note}
346+
It is unspecified
347+
whether a closure type\iref{expr.prim.lambda.closure} is a trivial type.
348+
\end{note}
349+
\end{itemdescr}
350+
314351
\indexlibraryglobal{is_pod}%
315352
\begin{itemdecl}
316353
template<class T> struct is_pod;

source/meta.tex

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@
192192
// \ref{meta.unary.prop}, type properties
193193
template<class T> struct is_const;
194194
template<class T> struct is_volatile;
195-
template<class T> struct is_trivial;
196195
template<class T> struct is_trivially_copyable;
197196
template<class T> struct is_standard_layout;
198197
template<class T> struct is_empty;
@@ -430,8 +429,6 @@
430429
constexpr bool @\libglobal{is_const_v}@ = is_const<T>::value;
431430
template<class T>
432431
constexpr bool @\libglobal{is_volatile_v}@ = is_volatile<T>::value;
433-
template<class T>
434-
constexpr bool @\libglobal{is_trivial_v}@ = is_trivial<T>::value;
435432
template<class T>
436433
constexpr bool @\libglobal{is_trivially_copyable_v}@ = is_trivially_copyable<T>::value;
437434
template<class T>
@@ -832,13 +829,6 @@
832829
\tcode{T} is volatile-qualified\iref{basic.type.qualifier} & \\ \rowsep
833830

834831

835-
\indexlibraryglobal{is_trivial}%
836-
\tcode{template<class T>}\br
837-
\tcode{struct is_trivial;} &
838-
\tcode{T} is a trivial type\iref{term.trivial.type} &
839-
\tcode{remove_all_extents_t<T>} shall be a complete
840-
type or \cv{}~\keyword{void}. \\ \rowsep
841-
842832
\indexlibraryglobal{is_trivially_copyable}%
843833
\tcode{template<class T>}\br
844834
\tcode{struct is_trivially_copyable;} &

source/strings.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
\pnum
77
This Clause describes components for manipulating sequences of
8-
any non-array trivial standard-layout\iref{term.standard.layout.type} type.
8+
any non-array trivially copyable standard-layout\iref{term.standard.layout.type} type \tcode{T}
9+
where \tcode{is_trivially_default_constructible_v<T>} is \tcode{true}.
910
Such types are called \defnx{char-like types}{char-like type},
1011
and objects of
1112
char-like types are called \defnx{char-like objects}{char-like object} or

source/support.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,10 @@
333333
\pnum
334334
The type
335335
\indexlibraryglobal{max_align_t}%
336-
\tcode{max_align_t} is a trivial standard-layout type whose alignment requirement
336+
\tcode{max_align_t} is a trivially copyable standard-layout type whose alignment requirement
337337
is at least as great as that of every scalar type, and whose alignment
338338
requirement is supported in every context\iref{basic.align}.
339+
\tcode{std::is_trivially_default_constructible_v<max_align_t>} is \tcode{true}.
339340

340341
\xrefc{7.19}
341342

0 commit comments

Comments
 (0)