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
86 changes: 57 additions & 29 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,26 @@
The implicitly-defined copy/move assignment operator for a class
returns the object for which the assignment operator is invoked,
that is, the object assigned to.

\pnum
If the declared return type of a defaulted copy/move assignment operator for a class
\tcode{X} contains a placeholder type,
the return type is deduced as if from \tcode{return r;},
where \tcode{r} is an lvalue of type \tcode{X}.

\pnum
\begin{example}
\begin{codeblock}
struct A {
decltype(auto) operator=(A&&) = default;
// OK, return type is \tcode{A\&}
};
struct B {
auto operator=(B&&) = default;
// error: return type is \tcode{B}, which violates\iref{dcl.fct.def.default}
};
\end{codeblock}
\end{example}
\indextext{assignment operator!move|)}
\indextext{assignment operator!copy|)}

Expand Down Expand Up @@ -6698,8 +6718,9 @@
\indextext{operator!equality!defaulted}%

\pnum
A defaulted equality operator function\iref{over.binary}
shall have a declared return type \tcode{bool}.
If the declared return type of a defaulted \tcode{==} operator function\iref{over.binary}
contains a placeholder type, its return type is deduced as if from \tcode{return true;}.
A defaulted \tcode{==} operator function shall have the return type \tcode{bool}.

\pnum
A defaulted \tcode{==} operator function for a class \tcode{C}
Expand All @@ -6716,8 +6737,8 @@
in the expanded lists of subobjects for \tcode{x} and \tcode{y}
(in increasing index order)
until the first index $i$
where $\tcode{x}_i\tcode{ == }\tcode{y}_i$ yields a result value which,
when contextually converted to \tcode{bool}, yields \tcode{false}.
where $\tcode{x}_i\tcode{ == }\tcode{y}_i$, contextually converted to \tcode{bool},
yields \tcode{false}.
The return value is \tcode{false} if such an index exists
and \tcode{true} otherwise.

Expand All @@ -6729,6 +6750,12 @@
friend bool operator==(const D& x, const D& y) = default;
// OK, returns \tcode{x.i == y.i}
};

struct E {
struct N {} n;
auto* operator==(const E&) const = default;
// error: cannot deduce \tcode{auto*} from \tcode{true}
};
\end{codeblock}
\end{example}

Expand Down Expand Up @@ -6797,43 +6824,40 @@
let $\tcode{x}_i$ be the elements of
the expanded list of subobjects for
an object \tcode{x} of type \tcode{C}.

\begin{itemize}
\item
If \tcode{R} is \keyword{auto}, then
If \tcode{R} contains a placeholder type, then
let $\cv{}_i~\tcode{R}_i$ be
the type of the expression $\tcode{x}_i\tcode{ <=> }\tcode{x}_i$.
The operator function is defined as deleted
if that expression is not usable or
if $\tcode{R}_i$ is not
a comparison category type\iref{cmp.categories.pre} for any $i$.
The return type is deduced as
the common comparison type (see below) of
$\tcode{R}_0$, $\tcode{R}_1$, $\dotsc$, $\tcode{R}_{n-1}$.
\item
Otherwise, \tcode{R} shall not contain a placeholder type.
If the synthesized three-way comparison of type \tcode{R}
If that expression is usable and $\tcode{R}_i$ is a comparison category type for all $i$,
let \tcode{Q} be the common comparison type (see below) of $\tcode{R}_0$, $\tcode{R}_1$, $\dotsc$, $\tcode{R}_{n-1}$.
Otherwise, let \tcode{Q} be \tcode{std::strong_ordering}.
The return type is deduced as if from \tcode{return Q(std::strong_ordering::equal);}.

\pnum
Let \tcode{S} be the (possibly deduced) return type of the defaulted three-way comparison operator function.
\tcode{S} shall be a comparison category type\iref{cmp.categories.pre}.

\pnum
If the synthesized three-way comparison of type \tcode{S}
between any objects $\tcode{x}_i$ and $\tcode{x}_i$
is not defined,
the operator function is defined as deleted.
\end{itemize}

\pnum
The return value of type \tcode{R}
The return value
of the defaulted three-way comparison operator function
with parameters \tcode{x} and \tcode{y} of the same type
with parameters \tcode{x} and \tcode{y}
is determined by comparing corresponding elements
$\tcode{x}_i$ and $\tcode{y}_i$
in the expanded lists of subobjects for \tcode{x} and \tcode{y}
(in increasing index order)
until the first index $i$ where
the synthesized three-way comparison of type \tcode{R}
the synthesized three-way comparison of type \tcode{S}
between $\tcode{x}_i$ and $\tcode{y}_i$
yields a result value $\tcode{v}_i$ where $\tcode{v}_i \mathrel{\tcode{!=}} 0$,
contextually converted to \tcode{bool}, yields \tcode{true}.
The return value is a copy of $\tcode{v}_i$
The return value is $\tcode{v}_i$
if such an index exists and
\tcode{static_cast<R>(std::strong_ordering::equal)} otherwise.
\tcode{static_cast<S>(std::strong_ordering::equal)} otherwise.

\pnum
The \defn{common comparison type} \tcode{U}
Expand Down Expand Up @@ -6863,14 +6887,18 @@

\pnum
\indextext{operator!comparison!secondary}%
A \defn{secondary comparison operator} is
A \defn{secondary comparison operator} $@$ is
a relational operator\iref{expr.rel} or the \tcode{!=} operator.
A defaulted operator function\iref{over.binary}
for a secondary comparison operator \tcode{@}
shall have a declared return type \tcode{bool}.

\pnum
The operator function with parameters \tcode{x} and \tcode{y}
If the declared return type of a defaulted secondary comparison
operator function contains a placeholder type,
its return type is deduced as if from \tcode{return true;}.
A defaulted secondary comparison operator function shall have
the return type \tcode{bool}.

\pnum
A defaulted secondary comparison operator function with parameters \tcode{x} and \tcode{y}
is defined as deleted if
\begin{itemize}
\item
Expand Down
22 changes: 22 additions & 0 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@
\end{codeblock}
\end{example}

\rSec2[diff.cpp26.class]{\ref*{class}: classes}

\diffref{class.spaceship}
\change
It is invalid for a defaulted three-way comparison operator of an empty class type
to return a type other than a comparison category type.
\rationale
Consistency with the existing restriction on defaulted three-way comparison
operators of non-empty class types.
\effect
A valid \CppXXVI{} program that contains a defaulted three-way comparison
operator with a return type that is not a comparison category type is ill-formed.
\begin{example}
\begin{codeblock}
struct U { U(std::strong_ordering); };
struct C {
U operator<=>(const C&) const = default;
// ill-formed; previously well-formed
};
\end{codeblock}
\end{example}

\rSec1[diff.cpp23]{\Cpp{} and ISO \CppXXIII{}}

\rSec2[diff.cpp23.general]{General}
Expand Down
21 changes: 21 additions & 0 deletions source/future.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
An implementation may declare library names and entities described in this Clause with the
\tcode{deprecated} attribute\iref{dcl.attr.deprecated}.

\rSec1[depr.oct]{Deprecated unprefixed octal literal}

\pnum
An \grammarterm{unprefixed-octal-literal}\iref{lex.icon} of the form
\begin{codeblock}
0 @\opt{'}@ @\grammarterm{octal-digit-sequence}@
\end{codeblock}
is deprecated.
\begin{note}
Use of an \grammarterm{unprefixed-octal-literal}, except the literal \tcode{0},
is deprecated because they are often confused with decimals.
\end{note}
\begin{example}
\begin{codeblock}
int zero = 0; // OK
int more_zeroes = 000; // deprecated
int unprefixed_octal = 042; // deprecated
int prefixed_octal = 0o42; // OK
\end{codeblock}
\end{example}

\rSec1[depr.local]{Non-local use of TU-local entities}

\pnum
Expand Down
36 changes: 18 additions & 18 deletions source/iostreams.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15812,46 +15812,46 @@
{lrlp{3.2in}}
\topline
\lhdr{Name} & \chdr{Value} & \chdr{POSIX} & \rhdr{Definition or notes} \\
& \chdr{(octal)} & \chdr{macro} & \\ \capsep
& & \chdr{macro} & \\ \capsep

\tcode{\libmember{none}{perms}} & \tcode{0} & &
There are no permissions set for the file. \\ \rowsep
\tcode{\libmember{owner_read}{perms}} & \tcode{0400} & \tcode{S_IRUSR} &
\tcode{\libmember{owner_read}{perms}} & \tcode{0o400} & \tcode{S_IRUSR} &
Read permission, owner \\ \rowsep
\tcode{\libmember{owner_write}{perms}} & \tcode{0200} & \tcode{S_IWUSR} &
\tcode{\libmember{owner_write}{perms}} & \tcode{0o200} & \tcode{S_IWUSR} &
Write permission, owner \\ \rowsep
\tcode{\libmember{owner_exec}{perms}} & \tcode{0100} & \tcode{S_IXUSR} &
\tcode{\libmember{owner_exec}{perms}} & \tcode{0o100} & \tcode{S_IXUSR} &
Execute/search permission, owner \\ \rowsep
\tcode{\libmember{owner_all}{perms}} & \tcode{0700} & \tcode{S_IRWXU} &
\tcode{\libmember{owner_all}{perms}} & \tcode{0o700} & \tcode{S_IRWXU} &
Read, write, execute/search by owner;\br
\tcode{owner_read | owner_write | owner_exec} \\ \rowsep
\tcode{\libmember{group_read}{perms}} & \tcode{040} & \tcode{S_IRGRP} &
\tcode{\libmember{group_read}{perms}} & \tcode{0o40} & \tcode{S_IRGRP} &
Read permission, group \\ \rowsep
\tcode{\libmember{group_write}{perms}} & \tcode{020} & \tcode{S_IWGRP} &
\tcode{\libmember{group_write}{perms}} & \tcode{0o20} & \tcode{S_IWGRP} &
Write permission, group \\ \rowsep
\tcode{\libmember{group_exec}{perms}} & \tcode{010} & \tcode{S_IXGRP} &
\tcode{\libmember{group_exec}{perms}} & \tcode{0o10} & \tcode{S_IXGRP} &
Execute/search permission, group \\ \rowsep
\tcode{\libmember{group_all}{perms}} & \tcode{070} & \tcode{S_IRWXG} &
\tcode{\libmember{group_all}{perms}} & \tcode{0o70} & \tcode{S_IRWXG} &
Read, write, execute/search by group;\br
\tcode{group_read | group_write | group_exec} \\ \rowsep
\tcode{\libmember{others_read}{perms}} & \tcode{04} & \tcode{S_IROTH} &
\tcode{\libmember{others_read}{perms}} & \tcode{0o4} & \tcode{S_IROTH} &
Read permission, others \\ \rowsep
\tcode{\libmember{others_write}{perms}} & \tcode{02} & \tcode{S_IWOTH} &
\tcode{\libmember{others_write}{perms}} & \tcode{0o2} & \tcode{S_IWOTH} &
Write permission, others \\ \rowsep
\tcode{\libmember{others_exec}{perms}} & \tcode{01} & \tcode{S_IXOTH} &
\tcode{\libmember{others_exec}{perms}} & \tcode{0o1} & \tcode{S_IXOTH} &
Execute/search permission, others \\ \rowsep
\tcode{\libmember{others_all}{perms}} & \tcode{07} & \tcode{S_IRWXO} &
\tcode{\libmember{others_all}{perms}} & \tcode{0o7} & \tcode{S_IRWXO} &
Read, write, execute/search by others;\br
\tcode{others_read | others_write | others_exec} \\ \rowsep
\tcode{\libmember{all}{perms}} & \tcode{0777} & &
\tcode{\libmember{all}{perms}} & \tcode{0o777} & &
\tcode{owner_all | group_all | others_all} \\ \rowsep
\tcode{\libmember{set_uid}{perms}} & \tcode{04000} & \tcode{S_ISUID} &
\tcode{\libmember{set_uid}{perms}} & \tcode{0o4000} & \tcode{S_ISUID} &
Set-user-ID on execution \\ \rowsep
\tcode{\libmember{set_gid}{perms}} & \tcode{02000} & \tcode{S_ISGID} &
\tcode{\libmember{set_gid}{perms}} & \tcode{0o2000} & \tcode{S_ISGID} &
Set-group-ID on execution \\ \rowsep
\tcode{\libmember{sticky_bit}{perms}} & \tcode{01000} & \tcode{S_ISVTX} &
\tcode{\libmember{sticky_bit}{perms}} & \tcode{0o1000} & \tcode{S_ISVTX} &
Operating system dependent. \\ \rowsep
\tcode{\libmember{mask}{perms}} & \tcode{07777} & &
\tcode{\libmember{mask}{perms}} & \tcode{0o7777} & &
\tcode{all | set_uid | set_gid | sticky_bit} \\ \rowsep
\tcode{\libmember{unknown}{perms}} & \tcode{0xFFFF} & &
The permissions are not known, such as when a \tcode{file_status} object
Expand Down
40 changes: 35 additions & 5 deletions source/lex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1223,8 +1223,19 @@

\begin{bnf}
\nontermdef{octal-literal}\br
prefixed-octal-literal\br
unprefixed-octal-literal
\end{bnf}

\begin{bnf}
\nontermdef{unprefixed-octal-literal}\br
\terminal{0}\br
octal-literal \opt{\terminal{'}} octal-digit
\terminal{0} \opt{\terminal{'}} octal-digit-sequence
\end{bnf}

\begin{bnf}
\nontermdef{prefixed-octal-literal}\br
octal-prefix octal-digit-sequence
\end{bnf}

\begin{bnf}
Expand Down Expand Up @@ -1253,11 +1264,22 @@
\terminal{1 2 3 4 5 6 7 8 9}
\end{bnf}

\begin{bnf}
\nontermdef{octal-prefix} \textnormal{one of}\br
\terminal{0o 0O}
\end{bnf}

\begin{bnf}
\nontermdef{hexadecimal-prefix} \textnormal{one of}\br
\terminal{0x 0X}
\end{bnf}

\begin{bnf}
\nontermdef{octal-digit-sequence}\br
octal-digit\br
octal-digit-sequence \opt{\terminal{'}} octal-digit
\end{bnf}

\begin{bnf}
\nontermdef{hexadecimal-digit-sequence}\br
hexadecimal-digit\br
Expand Down Expand Up @@ -1335,10 +1357,15 @@
\tcode{a} through \tcode{f} and \tcode{A} through \tcode{F}
have decimal values ten through fifteen.
\begin{example}
The number twelve can be written \tcode{12}, \tcode{014},
\tcode{0XC}, or \tcode{0b1100}. The \grammarterm{integer-literal}s \tcode{1048576},
\tcode{1'048'576}, \tcode{0X100000}, \tcode{0x10'0000}, and
\tcode{0'004'000'000} all have the same value.
The number twelve can be written \tcode{12}, \tcode{0o14},
\tcode{0XC}, or \tcode{0b1100}. The \grammarterm{integer-literal}s
\tcode{1048576},
\tcode{1'048'576},
\tcode{0X100000},
\tcode{0x10'0000},
\tcode{0O0004000000}, and
\tcode{0o0'004'000'000}
all have the same value.
\end{example}

\pnum
Expand Down Expand Up @@ -1455,6 +1482,9 @@
is ill-formed if it cannot be represented by \tcode{std::size_t}.
\end{note}

\pnum
An \grammarterm{unprefixed-octal-literal} that is not \tcode{0} is deprecated\iref{depr.oct}.

\rSec2[lex.ccon]{Character literals}

\indextext{literal!character}%
Expand Down
10 changes: 8 additions & 2 deletions source/overloading.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3816,9 +3816,15 @@

\rSec3[over.inc.default]{Defaulted function}

\pnum
If the declared return type of a defaulted postfix increment or
decrement operator for a type \tcode{C} contains a placeholder type,
the return type is deduced as if from \tcode{return r;},
where \tcode{r} is a prvalue of type \tcode{C}.

\pnum
A defaulted postfix increment or decrement operator function
for a type \tcode{C} shall be a non-template function that
for \tcode{C} shall be a non-template function that
\begin{itemize}
\item
has a first parameter of type ``reference to \tcode{C}'' or
Expand All @@ -3829,7 +3835,7 @@
is defined as defaulted in \tcode{C} or
in a context where \tcode{C} is complete, and
\item
has a declared return type of \tcode{C}.
has the return type \tcode{C}.
\end{itemize}
\begin{note}
A postfix increment or decrement operator
Expand Down
1 change: 1 addition & 0 deletions source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,7 @@
\hline
\lhdr{Name} & \rhdr{Value} \\ \capsep
\endhead
\defnxname{cpp_0o_octals} & \tcode{202611L} \\ \rowsep
\defnxname{cpp_aggregate_bases} & \tcode{201603L} \\ \rowsep
\defnxname{cpp_aggregate_nsdmi} & \tcode{201304L} \\ \rowsep
\defnxname{cpp_aggregate_paren_init} & \tcode{201902L} \\ \rowsep
Expand Down
Loading