Skip to content

Commit d043e4c

Browse files
H-G-HristovZingam
andauthored
[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 #59513 (comment), GH-59513 is not a blocker. Co-authored-by: Hristo Hristov <[email protected]>
1 parent 649cdfc commit d043e4c

File tree

8 files changed

+11
-27
lines changed

8 files changed

+11
-27
lines changed

libcxx/include/__compare/synth_three_way.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525

2626
// [expos.only.func]
2727

28-
// TODO MODULES restore the lamba to match the Standard.
29-
// See https://github.com/llvm/llvm-project/issues/57222
30-
//_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
31-
// []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
32-
template <class _Tp, class _Up>
33-
_LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up& __u)
28+
_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
3429
requires requires {
3530
{ __t < __u } -> __boolean_testable;
3631
{ __u < __t } -> __boolean_testable;
@@ -45,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up
4540
return weak_ordering::greater;
4641
return weak_ordering::equivalent;
4742
}
48-
}
43+
};
4944

5045
template <class _Tp, class _Up = _Tp>
5146
using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));

libcxx/include/array

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ template <class _Tp, size_t _Size>
423423
_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
424424
operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
425425
return std::lexicographical_compare_three_way(
426-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
426+
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
427427
}
428428

429429
#endif // _LIBCPP_STD_VER <= 17

libcxx/include/deque

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,7 @@ template <class _Tp, class _Allocator>
25312531
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
25322532
operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
25332533
return std::lexicographical_compare_three_way(
2534-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
2534+
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
25352535
}
25362536

25372537
#endif // _LIBCPP_STD_VER <= 17

libcxx/include/forward_list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,7 @@ template <class _Tp, class _Allocator>
15181518
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
15191519
operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
15201520
return std::lexicographical_compare_three_way(
1521-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
1521+
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
15221522
}
15231523

15241524
#endif // #if _LIBCPP_STD_VER <= 17

libcxx/include/list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ template <class _Tp, class _Allocator>
16801680
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
16811681
operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
16821682
return std::lexicographical_compare_three_way(
1683-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
1683+
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
16841684
}
16851685

16861686
#endif // _LIBCPP_STD_VER <= 17

libcxx/include/map

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,12 +1617,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
16171617
template <class _Key, class _Tp, class _Compare, class _Allocator>
16181618
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
16191619
operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
1620-
return std::lexicographical_compare_three_way(
1621-
__x.begin(),
1622-
__x.end(),
1623-
__y.begin(),
1624-
__y.end(),
1625-
std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
1620+
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
16261621
}
16271622

16281623
#endif // #if _LIBCPP_STD_VER <= 17
@@ -2136,12 +2131,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
21362131
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
21372132
operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
21382133
const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
2139-
return std::lexicographical_compare_three_way(
2140-
__x.begin(),
2141-
__x.end(),
2142-
__y.begin(),
2143-
__y.end(),
2144-
std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
2134+
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
21452135
}
21462136

21472137
#endif // #if _LIBCPP_STD_VER <= 17

libcxx/include/set

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
993993
template <class _Key, class _Allocator>
994994
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
995995
operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) {
996-
return std::lexicographical_compare_three_way(
997-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
996+
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
998997
}
999998

1000999
#endif // _LIBCPP_STD_VER <= 17
@@ -1454,7 +1453,7 @@ template <class _Key, class _Allocator>
14541453
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
14551454
operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {
14561455
return std::lexicographical_compare_three_way(
1457-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
1456+
__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
14581457
}
14591458

14601459
#endif // _LIBCPP_STD_VER <= 17

libcxx/include/vector

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,7 @@ template <class _Tp, class _Allocator>
29032903
_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
29042904
operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
29052905
return std::lexicographical_compare_three_way(
2906-
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
2906+
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
29072907
}
29082908

29092909
#endif // _LIBCPP_STD_VER <= 17

0 commit comments

Comments
 (0)