[libcxx-commits] [PATCH] D146094: [libc++][spaceship] Implement `operator<=>` for `stack`
Hristo Hristov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 22 14:36:06 PDT 2023
H-G-Hristov updated this revision to Diff 507513.
H-G-Hristov added a comment.
Herald added a subscriber: mikhail.ramalho.
Fix CI
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146094/new/
https://reviews.llvm.org/D146094
Files:
libcxx/docs/Status/SpaceshipProjects.csv
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,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>())); # Not yet supported
+ // `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)
@@ -266,6 +269,15 @@
friend
bool
operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
+
+#if _LIBCPP_STD_VER >= 20
+
+ template<class T1, three_way_comparable _C1>
+ friend
+ compare_three_way_result_t<_C1>
+ operator<=>(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
+
+#endif
};
#if _LIBCPP_STD_VER >= 17
@@ -346,6 +358,18 @@
return !(__y < __x);
}
+#if _LIBCPP_STD_VER >= 20
+
+template<class _Tp, three_way_comparable _Container>
+inline _LIBCPP_HIDE_FROM_ABI
+compare_three_way_result_t<_Container>
+operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+ return __x.c <=> __y.c;
+}
+
+#endif
+
template <class _Tp, class _Container>
inline _LIBCPP_INLINE_VISIBILITY
__enable_if_t<__is_swappable<_Container>::value, void>
Index: libcxx/docs/Status/SpaceshipProjects.csv
===================================================================
--- libcxx/docs/Status/SpaceshipProjects.csv
+++ libcxx/docs/Status/SpaceshipProjects.csv
@@ -45,7 +45,7 @@
| `[associative.set.syn] <https://wg21.link/associative.set.syn>`_ (`general <https://wg21.link/container.opt.reqmts>`_),"| multiset
| set",[expos.only.func],Unassigned,|Not Started|
| `[queue.ops] <https://wg21.link/queue.ops>`_,| queue,None,Unassigned,|Not Started|
-| `[stack.ops] <https://wg21.link/stack.ops>`_,| stack,None,Unassigned,|Not Started|
+| `[stack.ops] <https://wg21.link/stack.ops>`_,| `stack <https://reviews.llvm.org/D146094>`_,None,Hristo Hristov,|Complete|
| `[reverse.iter.cmp] <https://wg21.link/reverse.iter.cmp>`_,| `reverse_iterator <https://reviews.llvm.org/D113695>`_,None,Mikhail Maltsev,|Complete|
| `[move.iter.op.comp] <https://wg21.link/move.iter.op.comp>`_,| `move_iterator <https://reviews.llvm.org/D117656>`_,None,Arthur O'Dwyer,|Complete|
| `[counted.iter.cmp] <https://wg21.link/counted.iter.cmp>`_,| `counted_iterator <https://reviews.llvm.org/D106205>`_,None,Zoe Carver,|Complete|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146094.507513.patch
Type: text/x-patch
Size: 4021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230322/09b073ba/attachment.bin>
More information about the libcxx-commits
mailing list