[libcxx-commits] [PATCH] D146991: [libc++][NFC] Rename helper function for testing spaceship
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 27 11:12:13 PDT 2023
ldionne created this revision.
Herald added a subscriber: yaxunl.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
The helper is mis-named, since it won't work as-is on ordered containers
like set and map, because they rely on being able to store keys that are
partial_ordering::unordered, and that's UB for an ordered container.
This was most likely a typo or an unintended naming mistake, since
the function is only used with sequence containers anyway.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146991
Files:
libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
libcxx/test/support/test_container_comparisons.h
Index: libcxx/test/support/test_container_comparisons.h
===================================================================
--- libcxx/test/support/test_container_comparisons.h
+++ libcxx/test/support/test_container_comparisons.h
@@ -12,9 +12,9 @@
#include "test_comparisons.h"
-// Implementation detail of `test_ordered_container_spaceship`
+// Implementation detail of `test_sequence_container_spaceship`
template <template <typename...> typename Container, typename Elem, typename Order>
-constexpr void test_ordered_container_spaceship_with_type() {
+constexpr void test_sequence_container_spaceship_with_type() {
// Empty containers
{
Container<Elem> l1;
@@ -59,20 +59,20 @@
}
}
-// Tests the `operator<=>` on ordered containers
+// Tests the `operator<=>` on sequence containers
template <template <typename...> typename Container>
-constexpr bool test_ordered_container_spaceship() {
+constexpr bool test_sequence_container_spaceship() {
// The container should fulfil `std::three_way_comparable`
static_assert(std::three_way_comparable<Container<int>>);
// Test different comparison categories
- test_ordered_container_spaceship_with_type<Container, int, std::strong_ordering>();
- test_ordered_container_spaceship_with_type<Container, StrongOrder, std::strong_ordering>();
- test_ordered_container_spaceship_with_type<Container, WeakOrder, std::weak_ordering>();
- test_ordered_container_spaceship_with_type<Container, PartialOrder, std::partial_ordering>();
+ test_sequence_container_spaceship_with_type<Container, int, std::strong_ordering>();
+ test_sequence_container_spaceship_with_type<Container, StrongOrder, std::strong_ordering>();
+ test_sequence_container_spaceship_with_type<Container, WeakOrder, std::weak_ordering>();
+ test_sequence_container_spaceship_with_type<Container, PartialOrder, std::partial_ordering>();
// `LessAndEqComp` does not have `operator<=>`. ordering is sythesized based on `operator<`
- test_ordered_container_spaceship_with_type<Container, LessAndEqComp, std::weak_ordering>();
+ test_sequence_container_spaceship_with_type<Container, LessAndEqComp, std::weak_ordering>();
// Thanks to SFINAE, the following is not a compiler error but returns `false`
struct NonComparable {};
Index: libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
+++ libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
@@ -19,7 +19,7 @@
#include "test_container_comparisons.h"
int main(int, char**) {
- assert(test_ordered_container_spaceship<std::list>());
+ assert(test_sequence_container_spaceship<std::list>());
// `std::list` is not constexpr, so no `static_assert` test here.
return 0;
}
Index: libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
===================================================================
--- libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
+++ libcxx/test/libcxx/containers/sequences/forwardlist/compare.three_way.pass.cpp
@@ -19,7 +19,7 @@
#include "test_container_comparisons.h"
int main(int, char**) {
- assert(test_ordered_container_spaceship<std::forward_list>());
+ assert(test_sequence_container_spaceship<std::forward_list>());
// `std::forward_list` is not constexpr, so no `static_assert` test here.
return 0;
}
Index: libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
===================================================================
--- libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
+++ libcxx/test/libcxx/containers/sequences/deque/compare.three_way.pass.cpp
@@ -19,7 +19,7 @@
#include "test_container_comparisons.h"
int main(int, char**) {
- assert(test_ordered_container_spaceship<std::deque>());
+ assert(test_sequence_container_spaceship<std::deque>());
// `std::deque` is not constexpr, so no `static_assert` test here.
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146991.508737.patch
Type: text/x-patch
Size: 4084 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230327/efd26b9b/attachment.bin>
More information about the libcxx-commits
mailing list