https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/127342
Backport 248716f814d1d1fef88911d01a0b551d53c87c7a Requested by: @mordante >From 286f33ed20e4e7964dfa7d2988dd6234ad63dd7e Mon Sep 17 00:00:00 2001 From: Mark de Wever <ko...@xs4all.nl> Date: Sat, 15 Feb 2025 20:15:32 +0100 Subject: [PATCH] [libc++] Fixes (|multi)_set spaceship operator. (#127326) The operators did not have a _Compare template arguement. The fix updates the generic container test to use allocators for all types used. No other issues were found. Fixes: #127095 (cherry picked from commit 248716f814d1d1fef88911d01a0b551d53c87c7a) --- libcxx/include/set | 8 +- .../test/support/test_container_comparisons.h | 266 +++++++++++------- 2 files changed, 168 insertions(+), 106 deletions(-) diff --git a/libcxx/include/set b/libcxx/include/set index 2784e82760d7e..3c6ea360bd06c 100644 --- a/libcxx/include/set +++ b/libcxx/include/set @@ -1003,9 +1003,9 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, # else // _LIBCPP_STD_VER <= 17 -template <class _Key, class _Allocator> +template <class _Key, class _Compare, class _Allocator> _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> -operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) { +operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) { return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); } @@ -1470,9 +1470,9 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, # else // _LIBCPP_STD_VER <= 17 -template <class _Key, class _Allocator> +template <class _Key, class _Compare, class _Allocator> _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> -operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { +operator<=>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) { return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); } diff --git a/libcxx/test/support/test_container_comparisons.h b/libcxx/test/support/test_container_comparisons.h index 543c5899922d0..f7bf78e48a1f8 100644 --- a/libcxx/test/support/test_container_comparisons.h +++ b/libcxx/test/support/test_container_comparisons.h @@ -13,51 +13,52 @@ #include <functional> #include <set> +#include "test_allocator.h" #include "test_comparisons.h" // Implementation detail of `test_sequence_container_spaceship` -template <template <typename...> typename Container, typename Elem, typename Order> +template <template <typename...> typename Container, typename Elem, typename Allocator, typename Order> constexpr void test_sequence_container_spaceship_with_type() { // Empty containers { - Container<Elem> l1; - Container<Elem> l2; + Container<Elem, Allocator> l1; + Container<Elem, Allocator> l2; assert(testOrder(l1, l2, Order::equivalent)); } // Identical contents { - Container<Elem> l1{1, 1}; - Container<Elem> l2{1, 1}; + Container<Elem, Allocator> l1{1, 1}; + Container<Elem, Allocator> l2{1, 1}; assert(testOrder(l1, l2, Order::equivalent)); } // Less, due to contained values { - Container<Elem> l1{1, 1}; - Container<Elem> l2{1, 2}; + Container<Elem, Allocator> l1{1, 1}; + Container<Elem, Allocator> l2{1, 2}; assert(testOrder(l1, l2, Order::less)); } // Greater, due to contained values { - Container<Elem> l1{1, 3}; - Container<Elem> l2{1, 2}; + Container<Elem, Allocator> l1{1, 3}; + Container<Elem, Allocator> l2{1, 2}; assert(testOrder(l1, l2, Order::greater)); } // Shorter list { - Container<Elem> l1{1}; - Container<Elem> l2{1, 2}; + Container<Elem, Allocator> l1{1}; + Container<Elem, Allocator> l2{1, 2}; assert(testOrder(l1, l2, Order::less)); } // Longer list { - Container<Elem> l1{1, 2}; - Container<Elem> l2{1}; + Container<Elem, Allocator> l1{1, 2}; + Container<Elem, Allocator> l2{1}; assert(testOrder(l1, l2, Order::greater)); } // Unordered if constexpr (std::is_same_v<Elem, PartialOrder>) { - Container<Elem> l1{1, std::numeric_limits<int>::min()}; - Container<Elem> l2{1, 2}; + Container<Elem, Allocator> l1{1, std::numeric_limits<int>::min()}; + Container<Elem, Allocator> l2{1, 2}; assert(testOrder(l1, l2, Order::unordered)); } } @@ -69,13 +70,22 @@ constexpr bool test_sequence_container_spaceship() { static_assert(std::three_way_comparable<Container<int>>); // Test different comparison categories - 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>(); + test_sequence_container_spaceship_with_type<Container, int, std::allocator<int>, std::strong_ordering>(); + test_sequence_container_spaceship_with_type<Container, + StrongOrder, + test_allocator<StrongOrder>, + std::strong_ordering>(); + test_sequence_container_spaceship_with_type<Container, WeakOrder, std::allocator<WeakOrder>, std::weak_ordering>(); + test_sequence_container_spaceship_with_type<Container, + PartialOrder, + test_allocator<PartialOrder>, + std::partial_ordering>(); // `LessAndEqComp` does not have `operator<=>`. Ordering is synthesized based on `operator<` - test_sequence_container_spaceship_with_type<Container, LessAndEqComp, std::weak_ordering>(); + test_sequence_container_spaceship_with_type<Container, + LessAndEqComp, + std::allocator<LessAndEqComp>, + std::weak_ordering>(); // Thanks to SFINAE, the following is not a compiler error but returns `false` struct NonComparable {}; @@ -175,109 +185,114 @@ constexpr bool test_sequence_container_adaptor_spaceship() { } // Implementation detail of `test_ordered_map_container_spaceship` -template <template <typename...> typename Container, typename Key, typename Val, typename Order, typename Compare> +template <template <typename...> typename Container, + typename Key, + typename Val, + typename Allocator, + typename Order, + typename Compare> constexpr void test_ordered_map_container_spaceship_with_type(Compare comp) { // Empty containers { - Container<Key, Val, Compare> l1{{}, comp}; - Container<Key, Val, Compare> l2{{}, comp}; + Container<Key, Val, Compare, Allocator> l1{{}, comp}; + Container<Key, Val, Compare, Allocator> l2{{}, comp}; assert(testOrder(l1, l2, Order::equivalent)); } // Identical contents { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 1}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 1}}, comp}; assert(testOrder(l1, l2, Order::equivalent)); } // Less, due to contained values { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 1}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::less)); } // Greater, due to contained values { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 3}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 3}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::greater)); } // Shorter list { - Container<Key, Val, Compare> l1{{{1, 1}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::less)); } // Longer list { - Container<Key, Val, Compare> l1{{{1, 2}, {2, 2}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 2}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}}, comp}; assert(testOrder(l1, l2, Order::greater)); } // Unordered if constexpr (std::is_same_v<Val, PartialOrder>) { - Container<Key, Val, Compare> l1{{{1, 1}, {2, std::numeric_limits<int>::min()}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, std::numeric_limits<int>::min()}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::unordered)); } // Identical contents { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 1}, {2, 2}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 1}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::equivalent)); - Container<Key, Val, Compare> l3{{{1, 1}, {2, 1}, {2, 2}}, comp}; - Container<Key, Val, Compare> l4{{{2, 1}, {2, 2}, {1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l3{{{1, 1}, {2, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l4{{{2, 1}, {2, 2}, {1, 1}}, comp}; assert(testOrder(l3, l4, Order::equivalent)); } // Less, due to contained values { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 1}, {2, 1}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 1}, {2, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::less)); - Container<Key, Val, Compare> l3{{{1, 1}, {2, 1}, {2, 1}}, comp}; - Container<Key, Val, Compare> l4{{{2, 2}, {2, 2}, {1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l3{{{1, 1}, {2, 1}, {2, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l4{{{2, 2}, {2, 2}, {1, 1}}, comp}; assert(testOrder(l3, l4, Order::less)); } // Greater, due to contained values { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 3}, {2, 3}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 3}, {2, 3}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::greater)); - Container<Key, Val, Compare> l3{{{1, 1}, {2, 3}, {2, 3}}, comp}; - Container<Key, Val, Compare> l4{{{2, 2}, {2, 2}, {1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l3{{{1, 1}, {2, 3}, {2, 3}}, comp}; + Container<Key, Val, Compare, Allocator> l4{{{2, 2}, {2, 2}, {1, 1}}, comp}; assert(testOrder(l3, l4, Order::greater)); } // Shorter list { - Container<Key, Val, Compare> l1{{{1, 1}, {2, 2}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}, {2, 2}, {3, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}, {2, 2}, {3, 1}}, comp}; assert(testOrder(l1, l2, Order::less)); - Container<Key, Val, Compare> l3{{{1, 1}, {2, 2}}, comp}; - Container<Key, Val, Compare> l4{{{3, 1}, {2, 2}, {2, 2}, {1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l3{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l4{{{3, 1}, {2, 2}, {2, 2}, {1, 1}}, comp}; assert(testOrder(l3, l4, Order::less)); } // Longer list { - Container<Key, Val, Compare> l1{{{1, 2}, {2, 2}, {2, 2}, {3, 1}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 2}, {2, 2}, {2, 2}, {3, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}}, comp}; assert(testOrder(l1, l2, Order::greater)); - Container<Key, Val, Compare> l3{{{1, 2}, {2, 2}, {2, 2}, {3, 1}}, comp}; - Container<Key, Val, Compare> l4{{{2, 2}, {1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l3{{{1, 2}, {2, 2}, {2, 2}, {3, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l4{{{2, 2}, {1, 1}}, comp}; assert(testOrder(l3, l4, Order::greater)); } // Unordered if constexpr (std::is_same_v<Val, PartialOrder>) { - Container<Key, Val, Compare> l1{{{1, 1}, {2, std::numeric_limits<int>::min()}, {2, 3}}, comp}; - Container<Key, Val, Compare> l2{{{1, 1}, {2, 2}, {2, 3}}, comp}; + Container<Key, Val, Compare, Allocator> l1{{{1, 1}, {2, std::numeric_limits<int>::min()}, {2, 3}}, comp}; + Container<Key, Val, Compare, Allocator> l2{{{1, 1}, {2, 2}, {2, 3}}, comp}; assert(testOrder(l1, l2, Order::unordered)); - Container<Key, Val, Compare> l3{{{1, 1}, {2, std::numeric_limits<int>::min()}, {2, 3}}, comp}; - Container<Key, Val, Compare> l4{{{2, 3}, {2, 2}, {1, 1}}, comp}; + Container<Key, Val, Compare, Allocator> l3{{{1, 1}, {2, std::numeric_limits<int>::min()}, {2, 3}}, comp}; + Container<Key, Val, Compare, Allocator> l4{{{2, 3}, {2, 2}, {1, 1}}, comp}; assert(testOrder(l3, l4, Order::unordered)); } } @@ -293,94 +308,134 @@ constexpr bool test_ordered_map_container_spaceship() { static_assert(std::three_way_comparable<Container<int, int>>); // Test different comparison categories - test_ordered_map_container_spaceship_with_type<Container, int, int, std::strong_ordering>(std::less{}); - test_ordered_map_container_spaceship_with_type<Container, int, int, std::strong_ordering>(std::greater{}); - test_ordered_map_container_spaceship_with_type<Container, int, StrongOrder, std::strong_ordering>(std::less{}); - test_ordered_map_container_spaceship_with_type<Container, int, StrongOrder, std::strong_ordering>(std::greater{}); - test_ordered_map_container_spaceship_with_type<Container, int, WeakOrder, std::weak_ordering>(std::less{}); - test_ordered_map_container_spaceship_with_type<Container, int, WeakOrder, std::weak_ordering>(std::greater{}); - test_ordered_map_container_spaceship_with_type<Container, int, PartialOrder, std::partial_ordering>(std ::less{}); - test_ordered_map_container_spaceship_with_type<Container, int, PartialOrder, std::partial_ordering>(std ::greater{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + int, + std::allocator<std::pair<const int, int>>, + std::strong_ordering>(std::less{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + int, + test_allocator<std::pair<const int, int>>, + std::strong_ordering>(std::greater{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + StrongOrder, + std::allocator<std::pair<const int, StrongOrder>>, + std::strong_ordering>(std::less{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + StrongOrder, + test_allocator<std::pair<const int, StrongOrder>>, + std::strong_ordering>(std::greater{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + WeakOrder, + std::allocator<std::pair<const int, WeakOrder>>, + std::weak_ordering>(std::less{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + WeakOrder, + test_allocator<std::pair<const int, WeakOrder>>, + std::weak_ordering>(std::greater{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + PartialOrder, + std::allocator<std::pair<const int, PartialOrder>>, + std::partial_ordering>(std ::less{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + PartialOrder, + test_allocator<std::pair<const int, PartialOrder>>, + std::partial_ordering>(std ::greater{}); // `LessAndEqComp` does not have `operator<=>`. Ordering is synthesized based on `operator<` - test_ordered_map_container_spaceship_with_type<Container, int, LessAndEqComp, std::weak_ordering>(std::less{}); + test_ordered_map_container_spaceship_with_type<Container, + int, + LessAndEqComp, + std::allocator<std::pair<const int, LessAndEqComp>>, + std::weak_ordering>(std::less{}); return true; } // Implementation detail of `test_ordered_set_container_spaceship` -template <template <typename...> typename Container, typename Elem, typename Order, typename Compare> +template <template <typename...> typename Container, + typename Elem, + typename Allocator, + typename Order, + typename Compare> constexpr void test_ordered_set_spaceship_with_type(Compare comp) { // Empty containers { - Container<Elem, Compare> l1{{}, comp}; - Container<Elem, Compare> l2{{}, comp}; + Container<Elem, Compare, Allocator> l1{{}, comp}; + Container<Elem, Compare, Allocator> l2{{}, comp}; assert(testOrder(l1, l2, Order::equivalent)); } // Identical contents { - Container<Elem, Compare> l1{{1, 1, 2}, comp}; - Container<Elem, Compare> l2{{1, 1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, 1, 2}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 1, 2}, comp}; assert(testOrder(l1, l2, Order::equivalent)); } // Less, due to contained values { - Container<Elem, Compare> l1{{1, 1, 2, 3}, comp}; - Container<Elem, Compare> l2{{1, 2, 2, 4}, comp}; + Container<Elem, Compare, Allocator> l1{{1, 1, 2, 3}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2, 2, 4}, comp}; assert(testOrder(l1, l2, Order::less)); } // Greater, due to contained values { - Container<Elem, Compare> l1{{1, 2, 2, 4}, comp}; - Container<Elem, Compare> l2{{1, 1, 2, 3}, comp}; + Container<Elem, Compare, Allocator> l1{{1, 2, 2, 4}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 1, 2, 3}, comp}; assert(testOrder(l1, l2, Order::greater)); } // Shorter list { - Container<Elem, Compare> l1{{1, 1, 2, 2}, comp}; - Container<Elem, Compare> l2{{1, 1, 2, 2, 3}, comp}; + Container<Elem, Compare, Allocator> l1{{1, 1, 2, 2}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 1, 2, 2, 3}, comp}; assert(testOrder(l1, l2, Order::less)); } // Longer list { - Container<Elem, Compare> l1{{1, 1, 2, 2, 3}, comp}; - Container<Elem, Compare> l2{{1, 1, 2, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, 1, 2, 2, 3}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 1, 2, 2}, comp}; assert(testOrder(l1, l2, Order::greater)); } // Unordered if constexpr (std::is_same_v< Container<Elem>, std::multiset<PartialOrder>>) { if constexpr (std::is_same_v<Elem, PartialOrder> && std::is_same_v<Compare, decltype(std::less{})>) { - Container<Elem, Compare> l1{{1, std::numeric_limits<int>::min()}, comp}; - Container<Elem, Compare> l2{{1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, std::numeric_limits<int>::min()}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2}, comp}; assert(testOrder(l1, l2, Order::unordered)); } if constexpr (std::is_same_v<Elem, PartialOrder> && std::is_same_v<Compare, decltype(std::less{})>) { - Container<Elem, Compare> l1{{1, std::numeric_limits<int>::max()}, comp}; - Container<Elem, Compare> l2{{1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, std::numeric_limits<int>::max()}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2}, comp}; assert(testOrder(l1, l2, Order::unordered)); } } if constexpr (std::is_same_v< Container<Elem>, std::set<PartialOrder>>) { // Unordered values are not supported for `set` if constexpr (std::is_same_v<Elem, PartialOrder> && std::is_same_v<Compare, decltype(std::less{})>) { - Container<Elem, Compare> l1{{1, std::numeric_limits<int>::min()}, comp}; - Container<Elem, Compare> l2{{1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, std::numeric_limits<int>::min()}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2}, comp}; assert(testOrder(l1, l2, Order::less)); } if constexpr (std::is_same_v<Elem, PartialOrder> && std::is_same_v<Compare, decltype(std::less{})>) { - Container<Elem, Compare> l1{{1, std::numeric_limits<int>::max()}, comp}; - Container<Elem, Compare> l2{{1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, std::numeric_limits<int>::max()}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2}, comp}; assert(testOrder(l1, l2, Order::less)); } } if constexpr (std::is_same_v<Elem, PartialOrder> && std::is_same_v<Compare, decltype(std::greater{})>) { - Container<Elem, Compare> l1{{1, std::numeric_limits<int>::min()}, comp}; - Container<Elem, Compare> l2{{1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, std::numeric_limits<int>::min()}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2}, comp}; assert(testOrder(l1, l2, Order::less)); } if constexpr (std::is_same_v<Elem, PartialOrder> && std::is_same_v<Compare, decltype(std::greater{})>) { - Container<Elem, Compare> l1{{1, std::numeric_limits<int>::max()}, comp}; - Container<Elem, Compare> l2{{1, 2}, comp}; + Container<Elem, Compare, Allocator> l1{{1, std::numeric_limits<int>::max()}, comp}; + Container<Elem, Compare, Allocator> l2{{1, 2}, comp}; assert(testOrder(l1, l2, Order::less)); } } @@ -396,17 +451,24 @@ constexpr bool test_ordered_set_container_spaceship() { static_assert(std::three_way_comparable<Container<int>>); // Test different comparison categories - test_ordered_set_spaceship_with_type<Container, int, std::strong_ordering>(std::less{}); - test_ordered_set_spaceship_with_type<Container, int, std::strong_ordering>(std::greater{}); - test_ordered_set_spaceship_with_type<Container, StrongOrder, std::strong_ordering>(std::less{}); - test_ordered_set_spaceship_with_type<Container, StrongOrder, std::strong_ordering>(std::greater{}); - test_ordered_set_spaceship_with_type<Container, WeakOrder, std::weak_ordering>(std::less{}); - test_ordered_set_spaceship_with_type<Container, WeakOrder, std::weak_ordering>(std::greater{}); - test_ordered_set_spaceship_with_type<Container, PartialOrder, std::partial_ordering>(std::less{}); - test_ordered_set_spaceship_with_type<Container, PartialOrder, std::partial_ordering>(std::greater{}); + test_ordered_set_spaceship_with_type<Container, int, std::allocator<int>, std::strong_ordering>(std::less{}); + test_ordered_set_spaceship_with_type<Container, int, test_allocator<int>, std::strong_ordering>(std::greater{}); + test_ordered_set_spaceship_with_type<Container, StrongOrder, std::allocator<StrongOrder>, std::strong_ordering>( + std::less{}); + test_ordered_set_spaceship_with_type<Container, StrongOrder, test_allocator<StrongOrder>, std::strong_ordering>( + std::greater{}); + test_ordered_set_spaceship_with_type<Container, WeakOrder, std::allocator<WeakOrder>, std::weak_ordering>( + std::less{}); + test_ordered_set_spaceship_with_type<Container, WeakOrder, test_allocator<WeakOrder>, std::weak_ordering>( + std::greater{}); + test_ordered_set_spaceship_with_type<Container, PartialOrder, std::allocator<PartialOrder>, std::partial_ordering>( + std::less{}); + test_ordered_set_spaceship_with_type<Container, PartialOrder, test_allocator<PartialOrder>, std::partial_ordering>( + std::greater{}); // `LessAndEqComp` does not have `operator<=>`. Ordering is synthesized based on `operator<` - test_ordered_set_spaceship_with_type<Container, LessAndEqComp, std::weak_ordering>(std::less{}); + test_ordered_set_spaceship_with_type<Container, LessAndEqComp, std::allocator<LessAndEqComp>, std::weak_ordering>( + std::less{}); return true; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits