Skip to content

Commit 318bc0e

Browse files
committed
P3247R2 Deprecate the notion of trivial types
1 parent aed9756 commit 318bc0e

File tree

7 files changed

+55
-40
lines changed

7 files changed

+55
-40
lines changed

source/basic.tex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4921,11 +4921,6 @@
49214921
Scalar types, trivially copyable class types\iref{class.prop},
49224922
arrays of such types, and cv-qualified versions of these
49234923
types are collectively called \defnadjx{trivially copyable}{types}{type}.
4924-
\label{term.trivial.type}%
4925-
Scalar types, trivial class types\iref{class.prop},
4926-
arrays of such types, and cv-qualified versions of these
4927-
types are collectively called
4928-
\defnadjx{trivial}{types}{type}.
49294924
\label{term.standard.layout.type}%
49304925
Scalar types, standard-layout class
49314926
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
};
@@ -5942,7 +5933,7 @@
59425933
B bobj; // definition of \tcode{bobj}
59435934

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

source/containers.tex

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

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

95449545
\pnum
@@ -20618,13 +20619,13 @@
2061820619
\end{codeblock}
2061920620

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

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

source/future.tex

Lines changed: 36 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,47 @@
304306
any of the templates defined in this subclause is undefined,
305307
unless explicitly permitted by the specification of the corresponding template.
306308

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

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