Skip to content

Commit 5a7bb2f

Browse files
authored
Merge 2024-03 LWG Motion 16
P2944R3 Comparisons for reference_wrapper
2 parents 6569d4c + b4124f3 commit 5a7bb2f

File tree

2 files changed

+133
-34
lines changed

2 files changed

+133
-34
lines changed

source/support.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@
617617
#define @\defnlibxname{cpp_lib_constexpr_typeinfo}@ 202106L // freestanding, also in \libheader{typeinfo}
618618
#define @\defnlibxname{cpp_lib_constexpr_utility}@ 201811L // freestanding, also in \libheader{utility}
619619
#define @\defnlibxname{cpp_lib_constexpr_vector}@ 201907L // also in \libheader{vector}
620+
#define @\defnlibxname{cpp_lib_constrained_equality}@ 202403L // freestanding,
621+
// also in \libheader{utility}, \libheader{tuple}, \libheader{optional}, \libheader{variant}
620622
#define @\defnlibxname{cpp_lib_containers_ranges}@ 202202L
621623
// also in \libheader{vector}, \libheader{list}, \libheader{forward_list}, \libheader{map}, \libheader{set}, \libheader{unordered_map}, \libheader{unordered_set},
622624
// \libheader{deque}, \libheader{queue}, \libheader{stack}, \libheader{string}
@@ -754,6 +756,7 @@
754756
#define @\defnlibxname{cpp_lib_raw_memory_algorithms}@ 201606L // also in \libheader{memory}
755757
#define @\defnlibxname{cpp_lib_rcu}@ 202306L // also in \libheader{rcu}
756758
#define @\defnlibxname{cpp_lib_reference_from_temporary}@ 202202L // freestanding, also in \libheader{type_traits}
759+
#define @\defnlibxname{cpp_lib_reference_wrapper}@ 202403L // freestanding, also in \libheader{functional}
757760
#define @\defnlibxname{cpp_lib_remove_cvref}@ 201711L // freestanding, also in \libheader{type_traits}
758761
#define @\defnlibxname{cpp_lib_result_of_sfinae}@ 201210L
759762
// freestanding, also in \libheader{functional}, \libheader{type_traits}

source/utilities.tex

Lines changed: 130 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,11 @@
12821282

12831283
\begin{itemdescr}
12841284
\pnum
1285-
\expects
1286-
Each of \tcode{decltype(x.first == y.first)} and
1287-
\tcode{decltype(x.second == y.second)} models \exposconcept{boolean-testable}.
1285+
\constraints
1286+
\tcode{x.first == y.first} and \tcode{x.second == y.second} are
1287+
valid expressions and
1288+
each of \tcode{decltype(x.first == y.first)} and
1289+
\tcode{decltype(x.second == y.second)} models \exposconceptx{boolean-\newline testable}{boolean-testable}.
12881290

12891291
\pnum
12901292
\returns
@@ -2935,18 +2937,14 @@
29352937
For the first overload let \tcode{UTuple} be \tcode{tuple<UTypes...>}.
29362938

29372939
\pnum
2938-
\mandates
2940+
\constraints
29392941
For all \tcode{i},
29402942
where $0 \leq \tcode{i} < \tcode{sizeof...(TTypes)}$,
2941-
\tcode{get<i>(t) == get<i>(u)} is a valid expression.
2943+
\tcode{get<i>(t) == get<i>(u)} is a valid expression and
2944+
\tcode{decltype(get<i>(t) == get<i>(u))} models \exposconcept{boolean-testable}.
29422945
\tcode{sizeof...(TTypes)} equals
29432946
\tcode{tuple_size_v<UTuple>}.
29442947

2945-
\pnum
2946-
\expects
2947-
For all \tcode{i}, \tcode{decltype(get<i>(t) == get<i>(u))} models
2948-
\exposconcept{boolean-testable}.
2949-
29502948
\pnum
29512949
\returns
29522950
\tcode{true} if \tcode{get<i>(t) == get<i>(u)} for all
@@ -4399,7 +4397,7 @@
43994397

44004398
\begin{itemdescr}
44014399
\pnum
4402-
\mandates
4400+
\constraints
44034401
The expression \tcode{*x == *y} is well-formed and
44044402
its result is convertible to \tcode{bool}.
44054403
\begin{note}
@@ -4424,7 +4422,7 @@
44244422

44254423
\begin{itemdescr}
44264424
\pnum
4427-
\mandates
4425+
\constraints
44284426
The expression \tcode{*x != *y} is well-formed and
44294427
its result is convertible to \tcode{bool}.
44304428

@@ -4448,7 +4446,7 @@
44484446

44494447
\begin{itemdescr}
44504448
\pnum
4451-
\mandates
4449+
\constraints
44524450
\tcode{*x < *y} is well-formed
44534451
and its result is convertible to \tcode{bool}.
44544452

@@ -4472,7 +4470,7 @@
44724470

44734471
\begin{itemdescr}
44744472
\pnum
4475-
\mandates
4473+
\constraints
44764474
The expression \tcode{*x > *y} is well-formed and
44774475
its result is convertible to \tcode{bool}.
44784476

@@ -4496,7 +4494,7 @@
44964494

44974495
\begin{itemdescr}
44984496
\pnum
4499-
\mandates
4497+
\constraints
45004498
The expression \tcode{*x <= *y} is well-formed and
45014499
its result is convertible to \tcode{bool}.
45024500

@@ -4520,7 +4518,7 @@
45204518

45214519
\begin{itemdescr}
45224520
\pnum
4523-
\mandates
4521+
\constraints
45244522
The expression \tcode{*x >= *y} is well-formed and
45254523
its result is convertible to \tcode{bool}.
45264524

@@ -4589,7 +4587,7 @@
45894587

45904588
\begin{itemdescr}
45914589
\pnum
4592-
\mandates
4590+
\constraints
45934591
The expression \tcode{*x == v} is well-formed and
45944592
its result is convertible to \tcode{bool}.
45954593
\begin{note}
@@ -4608,7 +4606,7 @@
46084606

46094607
\begin{itemdescr}
46104608
\pnum
4611-
\mandates
4609+
\constraints
46124610
The expression \tcode{v == *x} is well-formed and
46134611
its result is convertible to \tcode{bool}.
46144612

@@ -4624,7 +4622,7 @@
46244622

46254623
\begin{itemdescr}
46264624
\pnum
4627-
\mandates
4625+
\constraints
46284626
The expression \tcode{*x != v} is well-formed and
46294627
its result is convertible to \tcode{bool}.
46304628

@@ -4640,7 +4638,7 @@
46404638

46414639
\begin{itemdescr}
46424640
\pnum
4643-
\mandates
4641+
\constraints
46444642
The expression \tcode{v != *x} is well-formed and
46454643
its result is convertible to \tcode{bool}.
46464644

@@ -4656,7 +4654,7 @@
46564654

46574655
\begin{itemdescr}
46584656
\pnum
4659-
\mandates
4657+
\constraints
46604658
The expression \tcode{*x < v} is well-formed and
46614659
its result is convertible to \tcode{bool}.
46624660

@@ -4672,7 +4670,7 @@
46724670

46734671
\begin{itemdescr}
46744672
\pnum
4675-
\mandates
4673+
\constraints
46764674
The expression \tcode{v < *x} is well-formed and
46774675
its result is convertible to \tcode{bool}.
46784676

@@ -4688,7 +4686,7 @@
46884686

46894687
\begin{itemdescr}
46904688
\pnum
4691-
\mandates
4689+
\constraints
46924690
The expression \tcode{*x > v} is well-formed and
46934691
its result is convertible to \tcode{bool}.
46944692

@@ -4704,7 +4702,7 @@
47044702

47054703
\begin{itemdescr}
47064704
\pnum
4707-
\mandates
4705+
\constraints
47084706
The expression \tcode{v > *x} is well-formed and
47094707
its result is convertible to \tcode{bool}.
47104708

@@ -4720,7 +4718,7 @@
47204718

47214719
\begin{itemdescr}
47224720
\pnum
4723-
\mandates
4721+
\constraints
47244722
The expression \tcode{*x <= v} is well-formed and
47254723
its result is convertible to \tcode{bool}.
47264724

@@ -4736,7 +4734,7 @@
47364734

47374735
\begin{itemdescr}
47384736
\pnum
4739-
\mandates
4737+
\constraints
47404738
The expression \tcode{v <= *x} is well-formed and
47414739
its result is convertible to \tcode{bool}.
47424740

@@ -4752,7 +4750,7 @@
47524750

47534751
\begin{itemdescr}
47544752
\pnum
4755-
\mandates
4753+
\constraints
47564754
The expression \tcode{*x >= v} is well-formed and
47574755
its result is convertible to \tcode{bool}.
47584756

@@ -4768,7 +4766,7 @@
47684766

47694767
\begin{itemdescr}
47704768
\pnum
4771-
\mandates
4769+
\constraints
47724770
The expression \tcode{v >= *x} is well-formed and
47734771
its result is convertible to \tcode{bool}.
47744772

@@ -5991,7 +5989,7 @@
59915989

59925990
\begin{itemdescr}
59935991
\pnum
5994-
\mandates
5992+
\constraints
59955993
\tcode{\exposid{GET}<$i$>(v) == \exposid{GET}<$i$>(w)} is a valid expression that is
59965994
convertible to \tcode{bool}, for all $i$.
59975995

@@ -6010,7 +6008,7 @@
60106008

60116009
\begin{itemdescr}
60126010
\pnum
6013-
\mandates
6011+
\constraints
60146012
\tcode{\exposid{GET}<$i$>(v) != \exposid{GET}<$i$>(w)} is a valid expression that is
60156013
convertible to \tcode{bool}, for all $i$.
60166014

@@ -6029,7 +6027,7 @@
60296027

60306028
\begin{itemdescr}
60316029
\pnum
6032-
\mandates
6030+
\constraints
60336031
\tcode{\exposid{GET}<$i$>(v) < \exposid{GET}<$i$>(w)} is a valid expression that is
60346032
convertible to \tcode{bool}, for all $i$.
60356033

@@ -6050,7 +6048,7 @@
60506048

60516049
\begin{itemdescr}
60526050
\pnum
6053-
\mandates
6051+
\constraints
60546052
\tcode{\exposid{GET}<$i$>(v) > \exposid{GET}<$i$>(w)} is a valid expression that is
60556053
convertible to \tcode{bool}, for all $i$.
60566054

@@ -6071,7 +6069,7 @@
60716069

60726070
\begin{itemdescr}
60736071
\pnum
6074-
\mandates
6072+
\constraints
60756073
\tcode{\exposid{GET}<$i$>(v) <= \exposid{GET}<$i$>(w)} is a valid expression that is
60766074
convertible to \tcode{bool}, for all $i$.
60776075

@@ -6092,7 +6090,7 @@
60926090

60936091
\begin{itemdescr}
60946092
\pnum
6095-
\mandates
6093+
\constraints
60966094
\tcode{\exposid{GET}<$i$>(v) >= \exposid{GET}<$i$>(w)} is a valid expression that is
60976095
convertible to \tcode{bool}, for all $i$.
60986096

@@ -10999,6 +10997,16 @@
1099910997
template<class... ArgTypes>
1100010998
constexpr invoke_result_t<T&, ArgTypes...> operator()(ArgTypes&&...) const
1100110999
noexcept(is_nothrow_invocable_v<T&, ArgTypes...>);
11000+
11001+
// \ref{refwrap.comparisons}, comparisons
11002+
friend constexpr bool operator==(reference_wrapper, reference_wrapper);
11003+
friend constexpr bool operator==(reference_wrapper, const T&);
11004+
friend constexpr bool operator==(reference_wrapper, reference_wrapper<const T>);
11005+
11006+
friend constexpr @\exposidnc{synth-three-way-result}@<T> operator<=>(reference_wrapper, reference_wrapper);
11007+
friend constexpr @\exposidnc{synth-three-way-result}@<T> operator<=>(reference_wrapper, const T&);
11008+
friend constexpr @\exposidnc{synth-three-way-result}@<T> operator<=>(reference_wrapper,
11009+
reference_wrapper<const T>);
1100211010
};
1100311011

1100411012
template<class T>
@@ -11017,6 +11025,12 @@
1101711025
\pnum
1101811026
The template parameter \tcode{T} of \tcode{reference_wrapper}
1101911027
may be an incomplete type.
11028+
\begin{note}
11029+
Using the comparison operators described in subclause \ref{refwrap.comparisons}
11030+
with \tcode{T} being an incomplete type
11031+
can lead to an ill-formed program
11032+
with no diagnostic required\iref{temp.point,temp.constr.atomic}.
11033+
\end{note}
1102011034

1102111035
\rSec3[refwrap.const]{Constructors}
1102211036

@@ -11120,6 +11134,88 @@
1112011134
\tcode{\placeholdernc{INVOKE}(get(), std::forward<ArgTypes>(args)...)}.\iref{func.require}
1112111135
\end{itemdescr}
1112211136

11137+
\rSec3[refwrap.comparisons]{Comparisons}
11138+
11139+
\begin{itemdecl}
11140+
friend constexpr bool operator==(reference_wrapper x, reference_wrapper y);
11141+
\end{itemdecl}
11142+
11143+
\begin{itemdescr}
11144+
\pnum
11145+
\constraints
11146+
The expression \tcode{x.get() == y.get()} is well-formed and
11147+
its result is convertible to \tcode{bool}.
11148+
11149+
\pnum
11150+
\returns
11151+
\tcode{x.get() == y.get()}.
11152+
\end{itemdescr}
11153+
11154+
\begin{itemdecl}
11155+
friend constexpr bool operator==(reference_wrapper x, const T& y);
11156+
\end{itemdecl}
11157+
11158+
\begin{itemdescr}
11159+
\pnum
11160+
\constraints
11161+
The expression \tcode{x.get() == y} is well-formed and
11162+
its result is convertible to \tcode{bool}.
11163+
11164+
\pnum
11165+
\returns
11166+
\tcode{x.get() == y}.
11167+
\end{itemdescr}
11168+
11169+
\begin{itemdecl}
11170+
friend constexpr bool operator==(reference_wrapper x, reference_wrapper<const T> y);
11171+
\end{itemdecl}
11172+
11173+
\begin{itemdescr}
11174+
\pnum
11175+
\constraints
11176+
\tcode{is_const_v<T>} is \tcode{false} and
11177+
the expression \tcode{x.get() == y.get()} is well-formed and
11178+
its result is convertible to \tcode{bool}.
11179+
11180+
\pnum
11181+
\returns
11182+
\tcode{x.get() == y.get()}.
11183+
\end{itemdescr}
11184+
11185+
\begin{itemdecl}
11186+
friend constexpr @\exposidnc{synth-three-way-result}@<T> operator<=>(reference_wrapper x, reference_wrapper y);
11187+
\end{itemdecl}
11188+
11189+
\begin{itemdescr}
11190+
\pnum
11191+
\returns
11192+
\tcode{\exposid{synth-three-way}(x.get(), y.get())}.
11193+
\end{itemdescr}
11194+
11195+
\begin{itemdecl}
11196+
friend constexpr @\exposidnc{synth-three-way-result}@<T> operator<=>(reference_wrapper x, const T& y);
11197+
\end{itemdecl}
11198+
11199+
\begin{itemdescr}
11200+
\pnum
11201+
\returns
11202+
\tcode{\exposid{synth-three-way}(x.get(), y)}.
11203+
\end{itemdescr}
11204+
11205+
\begin{itemdecl}
11206+
friend constexpr @\exposidnc{synth-three-way-result}@<T> operator<=>(reference_wrapper x,
11207+
reference_wrapper<const T> y);
11208+
\end{itemdecl}
11209+
11210+
\begin{itemdescr}
11211+
\pnum
11212+
\constraints
11213+
\tcode{is_const_v<T>} is \tcode{false}.
11214+
11215+
\pnum
11216+
\returns
11217+
\tcode{\exposid{synth-three-way}(x.get(), y.get())}.
11218+
\end{itemdescr}
1112311219

1112411220
\rSec3[refwrap.helpers]{Helper functions}
1112511221

0 commit comments

Comments
 (0)