[libcxx-commits] [PATCH] D144821: Updated: Cxx2bPapers.csv
Hristo Hristov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 26 05:10:50 PST 2023
H-G-Hristov updated this revision to Diff 500550.
H-G-Hristov added a comment.
- [libc++][spaceship] Implement `operator<=>` for `deque`
- Removed `test_container_comparisons.h`
Based on https://reviews.llvm.org/D132312
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144821/new/
https://reviews.llvm.org/D144821
Files:
libcxx/include/deque
libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
Index: libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <list>
+
+// template<class T, class Allocator>
+// synth-three-way-result<T> operator<=>(const deque<T, Allocator>& x,
+// const deque<T, Allocator>& y);
+
+#include <deque>
+#include <cassert>
+
+#include "test_container_comparisons.h"
+
+int main(int, char**) {
+ assert(test_ordered_container_spaceship<std::deque>());
+ // `std::deque` is not constexpr, so no `static_assert` test here.
+ return 0;
+}
\ No newline at end of file
Index: libcxx/include/deque
===================================================================
--- libcxx/include/deque
+++ libcxx/include/deque
@@ -134,15 +134,18 @@
template <class T, class Allocator>
bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y); // removed in C++20
template <class T, class Allocator>
- bool operator!=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ bool operator!=(const deque<T,Allocator>& x, const deque<T,Allocator>& y); // removed in C++20
template <class T, class Allocator>
- bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y); // removed in C++20
template <class T, class Allocator>
- bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y); // removed in C++20
template <class T, class Allocator>
- bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y); // removed in C++20
+template<class T, class Allocator>
+ synth-three-way-result<T> operator<=>(const deque<T, Allocator>& x,
+ const deque<T, Allocator>& y);
// specialized algorithms:
template <class T, class Allocator>
@@ -165,6 +168,7 @@
#include <__algorithm/equal.h>
#include <__algorithm/fill_n.h>
#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/lexicographical_compare_three_way.h>
#include <__algorithm/min.h>
#include <__algorithm/remove.h>
#include <__algorithm/remove_if.h>
@@ -2342,6 +2346,8 @@
return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
}
+#if _LIBCPP_STD_VER <= 17
+
template <class _Tp, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI
bool
@@ -2382,6 +2388,19 @@
return !(__y < __x);
}
+#else // _LIBCPP_STD_VER <= 17
+
+template<class _Tp, class _Allocator>
+inline _LIBCPP_HIDE_FROM_ABI
+__synth_three_way_result<_Tp>
+operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+ return lexicographical_compare_three_way(
+ __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
+}
+
+#endif // _LIBCPP_STD_VER <= 17
+
template <class _Tp, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI
void
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144821.500550.patch
Type: text/x-patch
Size: 3807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230226/b8aad46b/attachment.bin>
More information about the libcxx-commits
mailing list