Skip to content

Commit 9536509

Browse files
committed
[libc++] P2944R3: Constrained comparisions - the optional and reference_wrapper
Partially implements [P2944R3](https://wg21.link/P2944R3), which adds constrained comparisons to `optional` and `reference_wrapper`. Generalizes the test helpers in `test_comparisons.h` to support constrained comparisons. - [refwrap.comparisons](https://wg21.link/refwrap.comparisons) - [optional.relops](https://wg21.link/optional.relops) - [https://wg21.link/optional.comp.with.t](https://wg21.link/optional.comp.with.t) Closes llvm#136767 Closes llvm#138233 Relates to: llvm#135759
1 parent fe56c8f commit 9536509

File tree

17 files changed

+358
-160
lines changed

17 files changed

+358
-160
lines changed

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"`P2248R8 <https://wg21.link/P2248R8>`__","Enabling list-initialization for algorithms","2024-03 (Tokyo)","","",""
6060
"`P2810R4 <https://wg21.link/P2810R4>`__","``is_debugger_present`` ``is_replaceable``","2024-03 (Tokyo)","","",""
6161
"`P1068R11 <https://wg21.link/P1068R11>`__","Vector API for random number generation","2024-03 (Tokyo)","","",""
62-
"`P2944R3 <https://wg21.link/P2944R3>`__","Comparisons for ``reference_wrapper``","2024-03 (Tokyo)","|Partial|","","Implemented changes to ``reference_wrapper`` and ``pair``"
62+
"`P2944R3 <https://wg21.link/P2944R3>`__","Comparisons for ``reference_wrapper``","2024-03 (Tokyo)","|Partial|","","Not implemented ``tuple`` and ``variant``"
6363
"`P2642R6 <https://wg21.link/P2642R6>`__","Padded ``mdspan`` layouts","2024-03 (Tokyo)","","",""
6464
"`P3029R1 <https://wg21.link/P3029R1>`__","Better ``mdspan``'s CTAD","2024-03 (Tokyo)","|Complete|","19",""
6565
"","","","","",""

libcxx/include/__functional/reference_wrapper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
1212

1313
#include <__compare/synth_three_way.h>
14-
#include <__concepts/boolean_testable.h>
1514
#include <__config>
1615
#include <__functional/weak_result_type.h>
1716
#include <__memory/addressof.h>
1817
#include <__type_traits/desugars_to.h>
1918
#include <__type_traits/enable_if.h>
19+
#include <__type_traits/is_core_convertible.h>
2020
#include <__type_traits/invoke.h>
2121
#include <__type_traits/is_const.h>
2222
#include <__type_traits/remove_cvref.h>
@@ -75,23 +75,23 @@ class reference_wrapper : public __weak_result_type<_Tp> {
7575

7676
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)
7777
requires requires {
78-
{ __x.get() == __y.get() } -> __boolean_testable;
78+
{ __x.get() == __y.get() } -> __core_convertible_to<bool>;
7979
}
8080
{
8181
return __x.get() == __y.get();
8282
}
8383

8484
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)
8585
requires requires {
86-
{ __x.get() == __y } -> __boolean_testable;
86+
{ __x.get() == __y } -> __core_convertible_to<bool>;
8787
}
8888
{
8989
return __x.get() == __y;
9090
}
9191

9292
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)
9393
requires(!is_const_v<_Tp>) && requires {
94-
{ __x.get() == __y.get() } -> __boolean_testable;
94+
{ __x.get() == __y.get() } -> __core_convertible_to<bool>;
9595
}
9696
{
9797
return __x.get() == __y.get();

0 commit comments

Comments
 (0)