Skip to content

Commit f39c107

Browse files
authored
Merge 2018-06 CWG Motion 13
Fixes #2125
2 parents 9e59884 + 52e4554 commit f39c107

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

source/expressions.tex

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,13 @@
474474
\end{itemize}
475475
\end{itemize}
476476

477+
\pnum
478+
If one operand is of enumeration type
479+
and the other operand is of
480+
a different enumeration type or
481+
a floating-point type,
482+
this behavior is deprecated\iref{depr.arith.conv.enum}.
483+
477484
\rSec1[expr.prim]{Primary expressions}%
478485
\indextext{expression!primary|(}
479486

@@ -4964,6 +4971,8 @@
49644971

49654972
\pnum
49664973
If both operands have arithmetic types,
4974+
or one operand has integral type and
4975+
the other operand has unscoped enumeration type,
49674976
the usual arithmetic conversions\iref{expr.arith.conv} are applied to the operands.
49684977
Then:
49694978

@@ -5092,7 +5101,7 @@
50925101
\tcode{a<b<c} means \tcode{(a<b)<c} and \emph{not}
50935102
\tcode{(a<b)\&\&(b<c)}.
50945103
\end{example}
5095-
5104+
%
50965105
\indextext{operator!less than}%
50975106
\indextext{\idxcode{<}|see{operator, less than}}%
50985107
\indextext{operator!greater than}%
@@ -5110,8 +5119,19 @@
51105119
relational-expression \terminal{<=} compare-expression\br
51115120
relational-expression \terminal{>=} compare-expression
51125121
\end{bnf}
5122+
%
5123+
The
5124+
lvalue-to-rvalue\iref{conv.lval},
5125+
array-to-pointer\iref{conv.array},
5126+
and function-to-pointer\iref{conv.func}
5127+
standard conversions are performed on the operands.
5128+
The comparison is deprecated if
5129+
both operands were of array type
5130+
prior to these conversions\iref{depr.array.comp}.
51135131

5114-
The operands shall have arithmetic, enumeration, or pointer type. The
5132+
\pnum
5133+
The converted operands shall have arithmetic, enumeration, or pointer type.
5134+
The
51155135
operators \tcode{<} (less than), \tcode{>} (greater than), \tcode{<=}
51165136
(less than or equal to), and \tcode{>=} (greater than or equal to) all
51175137
yield \tcode{false} or \tcode{true}. The type of the result is
@@ -5178,7 +5198,18 @@
51785198

51795199
\pnum
51805200
The \tcode{==} (equal to) and the \tcode{!=} (not equal to) operators
5181-
group left-to-right. The operands shall have arithmetic, enumeration, pointer,
5201+
group left-to-right.
5202+
The
5203+
lvalue-to-rvalue\iref{conv.lval},
5204+
array-to-pointer\iref{conv.array},
5205+
and function-to-pointer\iref{conv.func}
5206+
standard conversions are performed on the operands.
5207+
The comparison is deprecated if
5208+
both operands were of array type
5209+
prior to these conversions\iref{depr.array.comp}.
5210+
5211+
\pnum
5212+
The converted operands shall have arithmetic, enumeration, pointer,
51825213
or pointer-to-member type, or type \tcode{std::nullptr_t}. The operators
51835214
\tcode{==} and \tcode{!=} both yield \tcode{true} or \tcode{false}, i.e., a
51845215
result of type \tcode{bool}. In each case below, the operands shall have the

source/future.tex

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@
1414
An implementation may declare library names and entities described in this Clause with the
1515
\tcode{deprecated} attribute\iref{dcl.attr.deprecated}.
1616

17+
\rSec1[depr.arith.conv.enum]{Arithmetic conversion on enumerations}
18+
19+
\pnum
20+
The ability to apply the usual arithmetic conversions\iref{expr.arith.conv}
21+
on operands where one is of enumeration type
22+
and the other is of a different enumeration type
23+
or a floating-point type
24+
is deprecated.
25+
\begin{note}
26+
Three-way comparisons\iref{expr.spaceship} between such operands are ill-formed.
27+
\end{note}
28+
\begin{example}
29+
\begin{codeblock}
30+
enum E1 { e };
31+
enum E2 { f };
32+
bool b = e <= 3.7; // deprecated
33+
int k = f - e; // deprecated
34+
auto cmp = e <=> f; // ill-formed
35+
\end{codeblock}
36+
\end{example}
37+
1738
\rSec1[depr.capture.this]{Implicit capture of \tcode{*this} by reference}
1839

1940
\pnum
@@ -33,6 +54,25 @@
3354
\end{codeblock}
3455
\end{example}
3556

57+
\rSec1[depr.array.comp]{Array comparisons}
58+
59+
\pnum
60+
Equality and relational comparisons (\ref{expr.eq}, \ref{expr.rel})
61+
between two operands of array type
62+
are deprecated.
63+
\begin{note}
64+
Three-way comparisons\iref{expr.spaceship} between such operands are ill-formed.
65+
\end{note}
66+
\begin{example}
67+
\begin{codeblock}
68+
int arr1[5];
69+
int arr2[5];
70+
bool same = arr1 == arr2; // deprecated, same as \tcode{\&arr[0] == \&arr[1]},
71+
// does not compare array contents
72+
auto cmp = arr1 <=> arr2; // ill-formed
73+
\end{codeblock}
74+
\end{example}
75+
3676
\rSec1[depr.static_constexpr]{Redeclaration of \tcode{static constexpr} data members}
3777

3878
\pnum

0 commit comments

Comments
 (0)