summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/debug
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-04-20 17:50:10 +0100
committerJonathan Wakely <jwakely@redhat.com>2020-04-20 17:50:10 +0100
commit93843da69772d271a7247ab2536280646086a5ce (patch)
treeac24f19cc4285e116b942136827d9de82eda5791 /libstdc++-v3/include/debug
parent8e1e6cdb8fb5ba4cb8a9836a4400f0317ffe0344 (diff)
libstdc++: Add comparison operators to associative containers
The last C++20 changes from P1614R2, "The Mothership has Landed" * include/bits/stl_map.h (map): Define operator<=> and remove operator< for C++20. * include/bits/stl_multimap.h (multimap): Likewise. * include/bits/stl_multiset.h (multiset): Likewise. * include/bits/stl_set.h (set): Likewise. * include/bits/stl_tree.h (_Rb_tree): Likewise. (_Rb_tree_iterator, _Rb_tree_const_iterator): Remove redundant operator!= for C++20. * include/debug/map.h (__gnu_debug::map): Define operator<=> for C++20. * include/debug/multimap.h (__gnu_debug::multimap): Likewise. * include/debug/multiset.h (__gnu_debug::multiset): Likewise. * include/debug/set.h (__gnu_debug::set): Likewise. * testsuite/23_containers/map/operators/cmp_c++20.cc: New test. * testsuite/23_containers/multimap/operators/cmp_c++20.cc: New test. * testsuite/23_containers/multiset/operators/cmp_c++20.cc: New test. * testsuite/23_containers/set/operators/cmp_c++20.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r--libstdc++-v3/include/debug/map.h10
-rw-r--r--libstdc++-v3/include/debug/multimap.h8
-rw-r--r--libstdc++-v3/include/debug/multiset.h10
-rw-r--r--libstdc++-v3/include/debug/set.h10
4 files changed, 35 insertions, 3 deletions
diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h
index e96fc31f522..adbabf62915 100644
--- a/libstdc++-v3/include/debug/map.h
+++ b/libstdc++-v3/include/debug/map.h
@@ -731,7 +731,7 @@ namespace __debug
map(initializer_list<pair<_Key, _Tp>>, _Allocator)
-> map<_Key, _Tp, less<_Key>, _Allocator>;
-#endif
+#endif // deduction guides
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
@@ -740,6 +740,13 @@ namespace __debug
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
+#if __cpp_lib_three_way_comparison
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline __detail::__synth3way_t<pair<const _Key, _Tp>>
+ operator<=>(const map<_Key, _Tp, _Compare, _Alloc>& __lhs,
+ const map<_Key, _Tp, _Compare, _Alloc>& __rhs)
+ { return __lhs._M_base() <=> __rhs._M_base(); }
+#else
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
@@ -774,6 +781,7 @@ namespace __debug
operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
+#endif // three-way comparison
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h
index 83de49e87e2..6cba52d35dc 100644
--- a/libstdc++-v3/include/debug/multimap.h
+++ b/libstdc++-v3/include/debug/multimap.h
@@ -621,6 +621,13 @@ namespace __debug
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
+#if __cpp_lib_three_way_comparison
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
+ inline __detail::__synth3way_t<pair<const _Key, _Tp>>
+ operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __lhs,
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __rhs)
+ { return __lhs._M_base() <=> __rhs._M_base(); }
+#else
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
@@ -655,6 +662,7 @@ namespace __debug
operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
+#endif // three-way comparison
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h
index fcbba339478..a2d5e717b34 100644
--- a/libstdc++-v3/include/debug/multiset.h
+++ b/libstdc++-v3/include/debug/multiset.h
@@ -584,7 +584,7 @@ namespace __debug
multiset(initializer_list<_Key>, _Allocator)
-> multiset<_Key, less<_Key>, _Allocator>;
-#endif
+#endif // deduction guides
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
@@ -592,6 +592,13 @@ namespace __debug
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
+#if __cpp_lib_three_way_comparison
+ template<typename _Key, typename _Compare, typename _Alloc>
+ inline __detail::__synth3way_t<_Key>
+ operator<=>(const multiset<_Key, _Compare, _Alloc>& __lhs,
+ const multiset<_Key, _Compare, _Alloc>& __rhs)
+ { return __lhs._M_base() <=> __rhs._M_base(); }
+#else
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
@@ -621,6 +628,7 @@ namespace __debug
operator>(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
+#endif // three-way comparison
template<typename _Key, typename _Compare, typename _Allocator>
void
diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h
index 093ff129f3e..210186623df 100644
--- a/libstdc++-v3/include/debug/set.h
+++ b/libstdc++-v3/include/debug/set.h
@@ -595,7 +595,7 @@ namespace __debug
set(initializer_list<_Key>, _Allocator)
-> set<_Key, less<_Key>, _Allocator>;
-#endif
+#endif // deduction guides
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
@@ -603,6 +603,13 @@ namespace __debug
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
+#if __cpp_lib_three_way_comparison
+ template<typename _Key, typename _Compare, typename _Alloc>
+ inline __detail::__synth3way_t<_Key>
+ operator<=>(const set<_Key, _Compare, _Alloc>& __lhs,
+ const set<_Key, _Compare, _Alloc>& __rhs)
+ { return __lhs._M_base() <=> __rhs._M_base(); }
+#else
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
@@ -632,6 +639,7 @@ namespace __debug
operator>(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
+#endif // three-way comparison
template<typename _Key, typename _Compare, typename _Allocator>
void