[libcxx-commits] [PATCH] D150188: [libc++][spaceship] Fixed `__debug_three_way_comp`'s `operator()`
Hristo Hristov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 1 11:08:41 PDT 2023
H-G-Hristov updated this revision to Diff 527517.
H-G-Hristov added a comment.
Try to fix CI
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150188/new/
https://reviews.llvm.org/D150188
Files:
libcxx/include/stack
libcxx/test/std/containers/container.adaptors/stack/compare.three_way.pass.cpp
Index: libcxx/test/std/containers/container.adaptors/stack/compare.three_way.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/containers/container.adaptors/stack/compare.three_way.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <stack>
+
+// template<class T, three_way_comparable Container>
+// compare_three_way_result_t<Container>
+// operator<=>(const stack<T, Container>& x, const stack<T, Container>& y);
+
+#include <cassert>
+#include <deque>
+#include <list>
+#include <stack>
+#include <vector>
+
+#include "test_container_comparisons.h"
+
+int main(int, char**) {
+ assert((test_ordered_container_adaptor_spaceship<std::stack, std::deque>()));
+ assert((test_ordered_container_adaptor_spaceship<std::stack, std::list>()));
+ assert((test_ordered_container_adaptor_spaceship<std::stack, std::vector>()));
+ assert((test_sequence_container_adaptor_spaceship<std::queue, custom_sequence_container>()));
+ // `std::stack` is not constexpr, so no `static_assert` test here.
+ return 0;
+}
Index: libcxx/include/stack
===================================================================
--- libcxx/include/stack
+++ libcxx/include/stack
@@ -89,6 +89,9 @@
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
+template<class T, three_way_comparable Container>
+ compare_three_way_result_t<Container>
+ operator<=>(const stack<T, Container>& x, const stack<T, Container>& y); // since C++20
template <class T, class Container>
void swap(stack<T, Container>& x, stack<T, Container>& y)
@@ -346,6 +349,16 @@
return !(__y < __x);
}
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp, three_way_comparable _Container>
+_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
+operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) {
+ return __x.__get_container() <=> __y.__get_container();
+}
+
+#endif
+
template <class _Tp, class _Container>
inline _LIBCPP_INLINE_VISIBILITY
__enable_if_t<__is_swappable<_Container>::value, void>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150188.527517.patch
Type: text/x-patch
Size: 2608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230601/f0b127b2/attachment.bin>
More information about the libcxx-commits
mailing list