Skip to content

Commit 2bb30a6

Browse files
authored
Merge 2022-11 LWG Motion 10
P2167R3 Improved Proposed Wording for LWG 2114 (contextually convertible to bool)
2 parents d8c5f61 + 04ad290 commit 2bb30a6

File tree

7 files changed

+56
-37
lines changed

7 files changed

+56
-37
lines changed

source/algorithms.tex

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@
151151
whenever an algorithm expects a function object\iref{function.objects} that,
152152
when applied to the result of dereferencing the corresponding iterator,
153153
returns a value testable as \tcode{true}.
154-
In other words,
155-
if an algorithm takes \tcode{Predicate pred} as its argument and
154+
If an algorithm takes \tcode{Predicate pred} as its argument and
156155
\tcode{first} as its iterator argument with value type \tcode{T},
157-
it should work correctly in the construct
158-
\tcode{pred(*first)} contextually converted to \tcode{bool}\iref{conv}.
156+
the expression \tcode{pred(*first)} shall be well-formed and
157+
the type \tcode{decltype(pred(*first))} shall model
158+
\exposconcept{boolean-testable}\iref{concept.booleantestable}.
159159
The function object \tcode{pred} shall not apply any non-constant function
160-
through the dereferenced iterator.
160+
through its argument.
161161
Given a glvalue \tcode{u} of type (possibly \keyword{const}) \tcode{T}
162162
that designates the same object as \tcode{*first},
163163
\tcode{pred(u)} shall be a valid expression
@@ -170,19 +170,21 @@
170170
to dereferencing an iterator and type \tcode{T}
171171
when \tcode{T} is part of the signature,
172172
returns a value testable as \tcode{true}.
173-
In other words,
174-
if an algorithm takes \tcode{BinaryPredicate binary_pred} as its argument and
173+
If an algorithm takes \tcode{BinaryPredicate binary_pred} as its argument and
175174
\tcode{first1} and \tcode{first2} as its iterator arguments
176175
with respective value types \tcode{T1} and \tcode{T2},
177-
it should work correctly in the construct
178-
\tcode{binary_pred(*first1, *first2)} contextually converted to \tcode{bool}\iref{conv}.
176+
the expression \tcode{binary_pred(*first1, *first2)} shall be well-formed and
177+
the type \tcode{decltype(binary_pred(*first1, *first2))} shall model
178+
\exposconcept{boolean-testable}.
179179
Unless otherwise specified,
180180
\tcode{BinaryPredicate} always takes the first iterator's \tcode{value_type}
181181
as its first argument, that is, in those cases when \tcode{T value}
182-
is part of the signature, it should work correctly in the construct
183-
\tcode{binary_pred(*first1, value)} contextually converted to \tcode{bool}\iref{conv}.
182+
is part of the signature,
183+
the expression \tcode{binary_pred(*first1, value)} shall be well-formed and
184+
the type \tcode{decltype(binary_pred(*first1, value))} shall model
185+
\exposconcept{boolean-testable}.
184186
\tcode{binary_pred} shall not apply any non-constant function
185-
through the dereferenced iterators.
187+
through any of its arguments.
186188
Given a glvalue \tcode{u} of type (possibly \keyword{const}) \tcode{T1}
187189
that designates the same object as \tcode{*first1}, and
188190
a glvalue \tcode{v} of type (possibly \keyword{const}) \tcode{T2}
@@ -6569,7 +6571,7 @@
65696571
named \tcode{BinaryPredicate}~\iref{algorithms.requirements}.
65706572
The return value of the function call operation
65716573
applied to an object of type \tcode{Compare},
6572-
when contextually converted to \tcode{bool}\iref{conv},
6574+
when converted to \tcode{bool},
65736575
yields \tcode{true}
65746576
if the first argument of the call is less than the second, and
65756577
\tcode{false} otherwise.

source/containers.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@
425425

426426
\pnum
427427
\result
428-
Convertible to \tcode{bool}.
428+
\tcode{bool}.
429429

430430
\pnum
431431
\returns
@@ -536,7 +536,7 @@
536536
\begin{itemdescr}
537537
\pnum
538538
\result
539-
Convertible to \tcode{bool}.
539+
\tcode{bool}.
540540

541541
\pnum
542542
\returns

source/iterators.tex

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@
20952095
& & \chdr{semantics} & \rhdr{pre-/post-condition} \\ \capsep
20962096
\endhead
20972097
\tcode{a != b} &
2098-
contextually convertible to \tcode{bool} &
2098+
\tcode{decltype(a != b)} models \exposconceptx{boolean-test\-able}{boolean-testable} &
20992099
\tcode{!(a == b)} &
21002100
\expects \orange{a}{b} is in the domain of \tcode{==}. \\ \rowsep
21012101

@@ -2383,25 +2383,21 @@
23832383
\tcode{*(a + n)} & \\ \rowsep
23842384

23852385
\tcode{a < b} &
2386-
contextually
2387-
convertible to \tcode{bool} &
2386+
\tcode{decltype(a < b)} models \exposconceptx{boolean-test\-able}{boolean-testable} &
23882387
\effects Equivalent to: \tcode{return b - a > 0;} &
23892388
\tcode{<} is a total ordering relation \\ \rowsep
23902389

23912390
\tcode{a > b} &
2392-
contextually
2393-
convertible to \tcode{bool} &
2391+
\tcode{decltype(a > b)} models \exposconceptx{boolean-test\-able}{boolean-testable} &
23942392
\tcode{b < a} &
23952393
\tcode{>} is a total ordering relation opposite to \tcode{<}. \\ \rowsep
23962394

23972395
\tcode{a >= b} &
2398-
contextually
2399-
convertible to \tcode{bool} &
2396+
\tcode{decltype(a >= b)} models \exposconceptx{boolean-test\-able}{boolean-testable} &
24002397
\tcode{!(a < b)} & \\ \rowsep
24012398

24022399
\tcode{a <= b} &
2403-
contextually
2404-
convertible to \tcode{bool}. &
2400+
\tcode{decltype(a <= b)} models \exposconceptx{boolean-test\-able}{boolean-testable} &
24052401
\tcode{!(a > b)} & \\
24062402
\end{libreqtab4b}
24072403

source/lib-intro.tex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@
16221622
\topline
16231623
\hdstyle{Expression} & \hdstyle{Return type} & \rhdr{Requirement} \\ \capsep
16241624
\tcode{a == b} &
1625-
convertible to \tcode{bool} &
1625+
\tcode{decltype(a == b)} models \exposconceptx{boolean-testa\-ble}{boolean-testable} &
16261626
\tcode{==} is an equivalence relation,
16271627
that is, it has the following properties:
16281628
\begin{itemize}
@@ -1640,7 +1640,7 @@
16401640
\topline
16411641
\hdstyle{Expression} & \hdstyle{Return type} & \hdstyle{Requirement} \\ \capsep
16421642
\tcode{a < b} &
1643-
convertible to \tcode{bool} &
1643+
\tcode{decltype(a < b)} models \exposconceptx{boolean-testa\-ble}{boolean-testable} &
16441644
\tcode{<} is a strict weak ordering relation\iref{alg.sorting} \\
16451645
\end{oldconcepttable}
16461646

@@ -1863,7 +1863,7 @@
18631863
a value of type (possibly \keyword{const}) \tcode{std::nullptr_t}.
18641864

18651865
\begin{oldconcepttable}{NullablePointer}{}{cpp17.nullablepointer}
1866-
{lll}
1866+
{lx{2in}l}
18671867
\topline
18681868
\lhdr{Expression} & \chdr{Return type} & \rhdr{Operational semantics} \\ \capsep
18691869
\tcode{P u(np);}\br &
@@ -1882,17 +1882,17 @@
18821882
\ensures \tcode{t == nullptr} \\ \rowsep
18831883

18841884
\tcode{a != b} &
1885-
contextually convertible to \tcode{bool} &
1885+
\tcode{decltype(a != b)} models \exposconcept{boolean-testable} &
18861886
\tcode{!(a == b)} \\ \rowsep
18871887

18881888
\tcode{a == np} &
1889-
contextually convertible to \tcode{bool} &
1889+
\tcode{decltype(a == np)} and \tcode{decltype(np == a)} each model \exposconcept{boolean-testable} &
18901890
\tcode{a == P()} \\
18911891
\tcode{np == a} &
18921892
&
18931893
\\ \rowsep
18941894
\tcode{a != np} &
1895-
contextually convertible to \tcode{bool} &
1895+
\tcode{decltype(a != np)} and \tcode{decltype(np != a)} each model \exposconcept{boolean-testable} &
18961896
\tcode{!(a == np)} \\
18971897
\tcode{np != a} &
18981898
&

source/support.tex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5047,7 +5047,9 @@
50475047
Otherwise, \tcode{strong_order(E, F)} if it is a well-formed expression.
50485048
\item
50495049
Otherwise, if the expressions \tcode{E == F} and \tcode{E < F}
5050-
are both well-formed and convertible to \tcode{bool},
5050+
are both well-formed and
5051+
each of \tcode{decltype(E == F)} and \tcode{decltype(E < F)} models
5052+
\exposconcept{boolean-testable},
50515053
\begin{codeblock}
50525054
E == F ? strong_ordering::equal :
50535055
E < F ? strong_ordering::less :
@@ -5079,7 +5081,9 @@
50795081
Otherwise, \tcode{weak_order(E, F)} if it is a well-formed expression.
50805082
\item
50815083
Otherwise, if the expressions \tcode{E == F} and \tcode{E < F}
5082-
are both well-formed and convertible to \tcode{bool},
5084+
are both well-formed and
5085+
each of \tcode{decltype(E == F)} and \tcode{decltype(E < F)} models
5086+
\exposconcept{boolean-testable},
50835087
\begin{codeblock}
50845088
E == F ? weak_ordering::equivalent :
50855089
E < F ? weak_ordering::less :
@@ -5112,7 +5116,9 @@
51125116
\item
51135117
Otherwise, if the expressions
51145118
\tcode{E == F}, \tcode{E < F}, and \tcode{F < E}
5115-
are all well-formed and convertible to \tcode{bool},
5119+
are all well-formed and
5120+
each of \tcode{decltype(E == F)} and \tcode{decltype(E < F)} models
5121+
\exposconcept{boolean-testable},
51165122
\begin{codeblock}
51175123
E == F ? partial_ordering::equivalent :
51185124
E < F ? partial_ordering::less :

source/threads.tex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@
3030
\pnum
3131
Throughout this Clause, the names of template parameters are used to express type
3232
requirements.
33-
If a template parameter is named \tcode{Predicate}, \tcode{operator()} applied to
34-
the template argument shall return a value that is convertible to \tcode{bool}.
33+
\tcode{Predicate} is a function object type\iref{function.objects}.
34+
Let \tcode{pred} denote an lvalue of type \tcode{Predicate}.
35+
Then the expression \tcode{pred()} shall be well-formed and
36+
the type \tcode{decltype(pred())} shall model
37+
\exposconcept{boolean-testable}\iref{concept.booleantestable}.
38+
The return value of \tcode{pred()}, converted to \tcode{bool},
39+
yields \tcode{true} if the corresponding test condition is satisfied, and
40+
\tcode{false} otherwise.
3541
If a template parameter is named \tcode{Clock},
3642
the corresponding template argument shall be a type \tcode{C}
3743
that meets the \oldconcept{Clock} requirements\iref{time.clock.req};

source/utilities.tex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,11 @@
12691269
\end{itemdecl}
12701270

12711271
\begin{itemdescr}
1272+
\pnum
1273+
\expects
1274+
Each of \tcode{decltype(x.first == y.first)} and
1275+
\tcode{decltype(x.second == y.second)} models \exposconcept{boolean-testable}.
1276+
12721277
\pnum
12731278
\returns
12741279
\tcode{x.first == y.first \&\& x.second == y.second}.
@@ -2907,11 +2912,15 @@
29072912
\mandates
29082913
For all \tcode{i},
29092914
where $0 \leq \tcode{i} < \tcode{sizeof...(TTypes)}$,
2910-
\tcode{get<i>(t) == get<i>(u)} is a valid expression
2911-
returning a type that is convertible to \tcode{bool}.
2915+
\tcode{get<i>(t) == get<i>(u)} is a valid expression.
29122916
\tcode{sizeof...(TTypes)} equals
29132917
\tcode{tuple_size_v<UTuple>}.
29142918

2919+
\pnum
2920+
\expects
2921+
For all \tcode{i}, \tcode{decltype(get<i>(t) == get<i>(u))} models
2922+
\exposconcept{boolean-testable}.
2923+
29152924
\pnum
29162925
\returns
29172926
\tcode{true} if \tcode{get<i>(t) == get<i>(u)} for all

0 commit comments

Comments
 (0)