diff --git a/libcxx/docs/Status/SpaceshipProjects.csv b/libcxx/docs/Status/SpaceshipProjects.csv --- a/libcxx/docs/Status/SpaceshipProjects.csv +++ b/libcxx/docs/Status/SpaceshipProjects.csv @@ -36,7 +36,7 @@ | `[string.cmp] `_,| `basic_string `_,None,Mark de Wever,|Complete| | `[string.view.comparison] `_,| `basic_string_view `_,None,Mark de Wever,|Complete| | `[array.syn] `_ (`general `_),| `array `_,[expos.only.func],Adrian Vogelsgesang,|In Progress| -| `[deque.syn] `_ (`general `_),| deque,[expos.only.func],Unassigned,|Not Started| +| `[deque.syn] `_ (`general `_),| deque ,[expos.only.func],Hristo Hristov,|Complete| | `[forward.list.syn] `_ (`general `_),| forward_list,[expos.only.func],Unassigned,|Not Started| | `[list.syn] `_ (`general `_),| `list `_,[expos.only.func],Adrian Vogelsgesang,|Complete| | `[vector.syn] `_ (`general `_),| `vector `_,[expos.only.func],Adrian Vogelsgesang,|In Progress| diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -134,15 +134,18 @@ template bool operator==(const deque& x, const deque& y); template - bool operator< (const deque& x, const deque& y); + bool operator< (const deque& x, const deque& y); // removed in C++20 template - bool operator!=(const deque& x, const deque& y); + bool operator!=(const deque& x, const deque& y); // removed in C++20 template - bool operator> (const deque& x, const deque& y); + bool operator> (const deque& x, const deque& y); // removed in C++20 template - bool operator>=(const deque& x, const deque& y); + bool operator>=(const deque& x, const deque& y); // removed in C++20 template - bool operator<=(const deque& x, const deque& y); + bool operator<=(const deque& x, const deque& y); // removed in C++20 +template + synth-three-way-result operator<=>(const deque& x, + const deque& y); // since C++20 // specialized algorithms: template @@ -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 inline _LIBCPP_HIDE_FROM_ABI bool @@ -2382,6 +2388,19 @@ return !(__y < __x); } +#else // _LIBCPP_STD_VER <= 17 + +template +inline _LIBCPP_HIDE_FROM_ABI +__synth_three_way_result<_Tp> +operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) +{ + return std::lexicographical_compare_three_way( + __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); +} + +#endif // _LIBCPP_STD_VER <= 17 + template inline _LIBCPP_HIDE_FROM_ABI void diff --git a/libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp new file mode 100644 --- /dev/null +++ b/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 + +// + +// template +// synth-three-way-result operator<=>(const deque& x, +// const deque& y); + +#include +#include + +#include "test_container_comparisons.h" + +int main(int, char**) { + assert(test_ordered_container_spaceship()); + // `std::deque` is not constexpr, so no `static_assert` test here. + return 0; +}