[libcxx-commits] [libcxx] WIP - [libc++][functional] P2944R3 (partial): Comparisons for ``reference_wrapper`` (``reference_wrapper`` operators only) (PR #88384)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sat May 4 04:48:06 PDT 2024
================
@@ -64,6 +67,62 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {
{
return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
}
+
+#if _LIBCPP_STD_VER >= 26
+
+ // [refwrap.comparisons], comparisons
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)
+ requires requires {
+ { __x.get() == __y.get() } -> __boolean_testable;
+ }
+ {
+ return __x.get() == __y.get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)
+ requires requires {
+ { __x.get() == __y } -> __boolean_testable;
+ }
+ {
+ return __x.get() == __y;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)
+ requires(!is_const_v<_Tp>) && requires {
+ { __x.get() == __y.get() } -> __boolean_testable;
+ }
+ {
+ return __x.get() == __y.get();
+ }
+
+ // `operator<=>`: Checks the constraints of `synth-three-way` as per https://wg21.link/LWG4071 directly
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y)
+ requires requires(const _Tp __t) {
+ { __t < __t } -> __boolean_testable;
----------------
mordante wrote:
This does not implement the proposed resolution of LWG4071. Can you update it to the current proposed resolution? We should also have additonal tests that detect objects that pass this constraint but do not satisfy the `__synth_three_way` concept.
https://github.com/llvm/llvm-project/pull/88384
More information about the libcxx-commits
mailing list