Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P3247R2 Deprecate the notion of trivial types #7439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
5 changes: 0 additions & 5 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4921,11 +4921,6 @@
Scalar types, trivially copyable class types\iref{class.prop},
arrays of such types, and cv-qualified versions of these
types are collectively called \defnadjx{trivially copyable}{types}{type}.
\label{term.trivial.type}%
Scalar types, trivial class types\iref{class.prop},
arrays of such types, and cv-qualified versions of these
types are collectively called
\defnadjx{trivial}{types}{type}.
\label{term.standard.layout.type}%
Scalar types, standard-layout class
types\iref{class.prop}, arrays of such types, and
Expand Down
19 changes: 5 additions & 14 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,6 @@
\item that has a trivial, non-deleted destructor\iref{class.dtor}.
\end{itemize}

\pnum
A \defnadj{trivial}{class} is a class that is trivially copyable and
has one or more eligible default constructors\iref{class.default.ctor},
all of which are trivial.
\begin{note}
In particular, a trivially copyable or trivial class does not have
virtual functions or virtual base classes.
\end{note}

\pnum
A class \tcode{S} is a \defnadj{standard-layout}{class} if it:
\begin{itemize}
Expand Down Expand Up @@ -272,25 +263,25 @@
\pnum
\begin{example}
\begin{codeblock}
struct N { // neither trivial nor standard-layout
struct N { // neither trivially copyable nor standard-layout
int i;
int j;
virtual ~N();
};

struct T { // trivial but not standard-layout
struct T { // trivially copyable but not standard-layout
int i;
private:
int j;
};

struct SL { // standard-layout but not trivial
struct SL { // standard-layout but not trivially copyable
int i;
int j;
~SL();
};

struct POD { // both trivial and standard-layout
struct POD { // both trivially copyable and standard-layout
int i;
int j;
};
Expand Down Expand Up @@ -5942,7 +5933,7 @@
B bobj; // definition of \tcode{bobj}

extern X xobj;
int* p3 = &xobj.i; // OK, \tcode{X} is a trivial class
int* p3 = &xobj.i; // OK, all constructors of \tcode{X} are trivial
X xobj;
\end{codeblock}
For another example,
Expand Down
19 changes: 10 additions & 9 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9537,8 +9537,9 @@

\pnum
For any $\tcode{N} > 0$,
if \tcode{is_trivial_v<T>} is \tcode{false}, then
no \tcode{inplace_vector<T, N>} member functions
if \tcode{T} is not trivially copyable or
\tcode{is_trivially_default_constructible_v<T>} is \tcode{false},
then no \tcode{inplace_vector<T, N>} member functions
are usable in constant expressions.

\pnum
Expand Down Expand Up @@ -20618,13 +20619,13 @@
\end{codeblock}

\pnum
Each of \tcode{layout_left}, \tcode{layout_right}, and \tcode{layout_stride}
meets the layout mapping policy requirements and is a trivial type.

\pnum
Each specialization of
\tcode{layout_left_padded} and \tcode{layout_right_padded}
meets the layout mapping policy requirements and is a trivial type.
Each of \tcode{layout_left}, \tcode{layout_right}, and \tcode{layout_stride},
as well as each specialization of
\tcode{layout_left_padded} and \tcode{layout_right_padded},
meets the layout mapping policy requirements and is a trivially copyable type.
Furthermore,
\tcode{is_trivially_default_constructible_v<T>} is \tcode{true}
for any such type \tcode{T}.

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

Expand Down
37 changes: 37 additions & 0 deletions source/future.tex
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@

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

\pnum
\label{term.trivial.type}%
A \defnadj{trivial}{class} is a class that is trivially copyable and
has one or more eligible default constructors, all of which are trivial.
\begin{note}
In particular,
a trivial class does not have virtual functions or virtual base classes.
\end{note}
A \defnadj{trivial}{type} is a scalar type, a trivial class,
an array of such a type, or a cv-qualified version of one of these types..

\pnum
\indextext{POD}%
A \term{POD class} is a class that is both a trivial class and a
standard-layout class, and has no non-static data members of type non-POD class
(or array thereof). A \term{POD type} is a scalar type, a POD class, an array
of such a type, or a cv-qualified version of one of these types.

\indexlibraryglobal{is_trivial}%
\begin{itemdecl}
template<class T> struct is_trivial;
\end{itemdecl}

\begin{itemdescr}
\pnum
\expects
\tcode{remove_all_extents_t<T>} shall be a complete type or \cv{} \keyword{void}.

\pnum
\remarks
\tcode{is_trivial<T>} is a \oldconcept{UnaryTypeTrait}\iref{meta.rqmts}
with a base characteristic of \tcode{true_type}
if \tcode{T} is a trivial type,
and \tcode{false_type} otherwise.

\pnum
\begin{note}
It is unspecified
whether a closure type\iref{expr.prim.lambda.closure} is a trivial type.
\end{note}
\end{itemdescr}

\indexlibraryglobal{is_pod}%
\begin{itemdecl}
template<class T> struct is_pod;
Expand Down
10 changes: 0 additions & 10 deletions source/meta.tex
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
// \ref{meta.unary.prop}, type properties
template<class T> struct is_const;
template<class T> struct is_volatile;
template<class T> struct is_trivial;
template<class T> struct is_trivially_copyable;
template<class T> struct is_standard_layout;
template<class T> struct is_empty;
Expand Down Expand Up @@ -430,8 +429,6 @@
constexpr bool @\libglobal{is_const_v}@ = is_const<T>::value;
template<class T>
constexpr bool @\libglobal{is_volatile_v}@ = is_volatile<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivial_v}@ = is_trivial<T>::value;
template<class T>
constexpr bool @\libglobal{is_trivially_copyable_v}@ = is_trivially_copyable<T>::value;
template<class T>
Expand Down Expand Up @@ -832,13 +829,6 @@
\tcode{T} is volatile-qualified\iref{basic.type.qualifier} & \\ \rowsep


\indexlibraryglobal{is_trivial}%
\tcode{template<class T>}\br
\tcode{struct is_trivial;} &
\tcode{T} is a trivial type\iref{term.trivial.type} &
\tcode{remove_all_extents_t<T>} shall be a complete
type or \cv{}~\keyword{void}. \\ \rowsep

\indexlibraryglobal{is_trivially_copyable}%
\tcode{template<class T>}\br
\tcode{struct is_trivially_copyable;} &
Expand Down
3 changes: 2 additions & 1 deletion source/strings.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

\pnum
This Clause describes components for manipulating sequences of
any non-array trivial standard-layout\iref{term.standard.layout.type} type.
any non-array trivially copyable standard-layout\iref{term.standard.layout.type} type \tcode{T}
where \tcode{is_trivially_default_constructible_v<T>} is \tcode{true}.
Such types are called \defnx{char-like types}{char-like type},
and objects of
char-like types are called \defnx{char-like objects}{char-like object} or
Expand Down
3 changes: 2 additions & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,10 @@
\pnum
The type
\indexlibraryglobal{max_align_t}%
\tcode{max_align_t} is a trivial standard-layout type whose alignment requirement
\tcode{max_align_t} is a trivially copyable standard-layout type whose alignment requirement
is at least as great as that of every scalar type, and whose alignment
requirement is supported in every context\iref{basic.align}.
\tcode{std::is_trivially_default_constructible_v<max_align_t>} is \tcode{true}.

\xrefc{7.19}

Expand Down
Loading