|
10 | 10 | #ifndef _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
|
11 | 11 | #define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
|
12 | 12 |
|
| 13 | +#include <__compare/synth_three_way.h> |
| 14 | +#include <__concepts/boolean_testable.h> |
13 | 15 | #include <__config>
|
14 | 16 | #include <__functional/invoke.h>
|
15 | 17 | #include <__functional/weak_result_type.h>
|
16 | 18 | #include <__memory/addressof.h>
|
17 | 19 | #include <__type_traits/enable_if.h>
|
| 20 | +#include <__type_traits/is_const.h> |
18 | 21 | #include <__type_traits/remove_cvref.h>
|
19 | 22 | #include <__type_traits/void_t.h>
|
20 | 23 | #include <__utility/declval.h>
|
@@ -64,6 +67,54 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {
|
64 | 67 | {
|
65 | 68 | return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
|
66 | 69 | }
|
| 70 | + |
| 71 | +#if _LIBCPP_STD_VER >= 26 |
| 72 | + |
| 73 | + // [refwrap.comparisons], comparisons |
| 74 | + |
| 75 | + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y) |
| 76 | + requires requires { |
| 77 | + { __x.get() == __y.get() } -> __boolean_testable; |
| 78 | + } |
| 79 | + { |
| 80 | + return __x.get() == __y.get(); |
| 81 | + } |
| 82 | + |
| 83 | + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y) |
| 84 | + requires requires { |
| 85 | + { __x.get() == __y } -> __boolean_testable; |
| 86 | + } |
| 87 | + { |
| 88 | + return __x.get() == __y; |
| 89 | + } |
| 90 | + |
| 91 | + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y) |
| 92 | + requires(!is_const_v<_Tp>) && requires { |
| 93 | + { __x.get() == __y.get() } -> __boolean_testable; |
| 94 | + } |
| 95 | + { |
| 96 | + return __x.get() == __y.get(); |
| 97 | + } |
| 98 | + |
| 99 | + _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y) |
| 100 | + requires requires { std::__synth_three_way(__x.get(), __y.get()); } |
| 101 | + { |
| 102 | + return std::__synth_three_way(__x.get(), __y.get()); |
| 103 | + } |
| 104 | + |
| 105 | + _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, const _Tp& __y) |
| 106 | + requires requires { std::__synth_three_way(__x.get(), __y); } |
| 107 | + { |
| 108 | + return std::__synth_three_way(__x.get(), __y); |
| 109 | + } |
| 110 | + |
| 111 | + _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y) |
| 112 | + requires(!is_const_v<_Tp>) && requires { std::__synth_three_way(__x.get(), __y.get()); } |
| 113 | + { |
| 114 | + return std::__synth_three_way(__x.get(), __y.get()); |
| 115 | + } |
| 116 | + |
| 117 | +#endif // _LIBCPP_STD_VER >= 26 |
67 | 118 | };
|
68 | 119 |
|
69 | 120 | #if _LIBCPP_STD_VER >= 17
|
|
0 commit comments