[libcxx-commits] [libcxx] [libc++] Restore `__synth_three_way` lambda (PR #90398)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 28 08:23:43 PDT 2024


https://github.com/H-G-Hristov updated https://github.com/llvm/llvm-project/pull/90398

>From af02e095897cc5ecf40b752f26e353961104c708 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Thu, 18 Apr 2024 20:32:16 +0300
Subject: [PATCH] [libc++] Restore `__synth_three_way` lambda

---
 libcxx/include/__compare/synth_three_way.h |  9 ++-------
 libcxx/include/array                       |  2 +-
 libcxx/include/deque                       |  2 +-
 libcxx/include/forward_list                |  2 +-
 libcxx/include/list                        |  2 +-
 libcxx/include/map                         | 14 ++------------
 libcxx/include/set                         |  5 ++---
 libcxx/include/vector                      |  2 +-
 8 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/libcxx/include/__compare/synth_three_way.h b/libcxx/include/__compare/synth_three_way.h
index 6420d1362db0ce..e48ce497998368 100644
--- a/libcxx/include/__compare/synth_three_way.h
+++ b/libcxx/include/__compare/synth_three_way.h
@@ -25,12 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // [expos.only.func]
 
-// TODO MODULES restore the lamba to match the Standard.
-// See https://github.com/llvm/llvm-project/issues/57222
-//_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
-//  []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
-template <class _Tp, class _Up>
-_LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up& __u)
+_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
   requires requires {
     { __t < __u } -> __boolean_testable;
     { __u < __t } -> __boolean_testable;
@@ -45,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up
       return weak_ordering::greater;
     return weak_ordering::equivalent;
   }
-}
+};
 
 template <class _Tp, class _Up = _Tp>
 using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
diff --git a/libcxx/include/array b/libcxx/include/array
index 977f913c3e748a..dbdd2b3f4b24b0 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -423,7 +423,7 @@ template <class _Tp, size_t _Size>
 _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
 operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/deque b/libcxx/include/deque
index d42669dd6dc0e1..aa89c8081b22bc 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -2523,7 +2523,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
 operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 1dcbe8f88b90db..03fcf177305073 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -1524,7 +1524,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
 operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // #if _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/list b/libcxx/include/list
index 9de3d1f60a1f79..69b7039b4060aa 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -1687,7 +1687,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
 operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/map b/libcxx/include/map
index 5b6ec9d3a21936..8e64bab3252124 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1623,12 +1623,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
 template <class _Key, class _Tp, class _Compare, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
 operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
-  return std::lexicographical_compare_three_way(
-      __x.begin(),
-      __x.end(),
-      __y.begin(),
-      __y.end(),
-      std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
+  return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // #if _LIBCPP_STD_VER <= 17
@@ -2144,12 +2139,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
 operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
             const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
-  return std::lexicographical_compare_three_way(
-      __x.begin(),
-      __x.end(),
-      __y.begin(),
-      __y.end(),
-      std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
+  return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
 }
 
 #endif // #if _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/set b/libcxx/include/set
index e2e87e4cdcfe3b..6706a9a8cbc0bb 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -996,8 +996,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
 template <class _Key, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
 operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) {
-  return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
+  return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
@@ -1457,7 +1456,7 @@ template <class _Key, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
 operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17
diff --git a/libcxx/include/vector b/libcxx/include/vector
index 7303d7ec0b24a3..f8437b0aab09c0 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2906,7 +2906,7 @@ template <class _Tp, class _Allocator>
 _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
 operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
   return std::lexicographical_compare_three_way(
-      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
+      __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
 }
 
 #endif // _LIBCPP_STD_VER <= 17



More information about the libcxx-commits mailing list