[libcxx-commits] [libcxx] d043e4c - [libc++] Restore `__synth_three_way` lambda (#90398)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 7 10:49:14 PDT 2024
Author: Hristo Hristov
Date: 2024-07-07T20:49:10+03:00
New Revision: d043e4c322489fa5b9f6363e3c83984219c2b602
URL: https://github.com/llvm/llvm-project/commit/d043e4c322489fa5b9f6363e3c83984219c2b602
DIFF: https://github.com/llvm/llvm-project/commit/d043e4c322489fa5b9f6363e3c83984219c2b602.diff
LOG: [libc++] Restore `__synth_three_way` lambda (#90398)
Restore `__synth_three_way` lambda to match the Standard.
GH-57222 is done, restoring the Standard wording implementation should
be possible.
https://github.com/llvm/llvm-project/blob/df28d4412c1d21b0e18896c92ac77d2fac7729f1/libcxx/include/__compare/synth_three_way.h#L28
According to comment
https://github.com/llvm/llvm-project/issues/59513#issuecomment-2068338762,
GH-59513 is not a blocker.
Co-authored-by: Hristo Hristov <zingam at outlook.com>
Added:
Modified:
libcxx/include/__compare/synth_three_way.h
libcxx/include/array
libcxx/include/deque
libcxx/include/forward_list
libcxx/include/list
libcxx/include/map
libcxx/include/set
libcxx/include/vector
Removed:
################################################################################
diff --git a/libcxx/include/__compare/synth_three_way.h b/libcxx/include/__compare/synth_three_way.h
index 6420d1362db0c..e48ce49799836 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 accfe15533e98..6ffde852f4802 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 aee4764859dd2..4fc994a6e229b 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -2531,7 +2531,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 3731d3f6cf6d1..1ae19d23f88cc 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -1518,7 +1518,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 1678559a841dd..929c84de7be44 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -1680,7 +1680,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 4b2f3fc71cbfe..02bd17ccb4e8c 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1617,12 +1617,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
@@ -2136,12 +2131,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 9a2eb12d0a25a..9453358379869 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -993,8 +993,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
@@ -1454,7 +1453,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 299ad8c9b23f2..aaf51d18fe30f 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2903,7 +2903,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