You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[libc++] Make flat_(multi)map's iterators require operator<=>
Flat container adaptors require the iterators of underlying containers
to be random access, and it is required that random access container
iterators must support three-way comparison
([container.reqmts]/39 - /41).
As a result, we can and perhaps should reject containers with unexpected
iterator types, as they're invalid since C++20.
using FMap = std::flat_map<int, int, std::less<int>, KeyCont, MinSequenceContainer<int>>;
76
+
FMap m;
77
+
// expected-error-re@*:* {{static assertion failed due to requirement 'is_same_v<std::weak_ordering, std::strong_ordering>'{{.*}}three-way comparison between random accesss container iterators must return std::strong_ordering}}
78
+
// expected-error-re@*:* {{no viable conversion from returned value of type{{.*}}}}
Copy file name to clipboardExpand all lines: libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.iterators/iterator_comparison.pass.cpp
+26-29
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,6 @@ void test() {
28
28
using Key = typename KeyContainer::value_type;
29
29
using Value = typename ValueContainer::value_type;
30
30
using M = std::flat_multimap<Key, Value, std::less<Key>, KeyContainer, ValueContainer>;
31
-
using KI = typename KeyContainer::iterator;
32
31
using I = M::iterator;
33
32
using CI = M::const_iterator;
34
33
using RI = M::reverse_iterator;
@@ -115,34 +114,32 @@ void test() {
115
114
assert(cri2 >= cri2);
116
115
assert(!(cri1 >= cri2));
117
116
118
-
ifconstexpr (std::three_way_comparable<KI>) {
119
-
static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
using FMap = std::flat_multimap<int, int, std::less<int>, KeyCont, MinSequenceContainer<int>>;
76
+
FMap m;
77
+
// expected-error-re@*:* {{static assertion failed due to requirement 'is_same_v<std::weak_ordering, std::strong_ordering>'{{.*}}three-way comparison between random accesss container iterators must return std::strong_ordering}}
78
+
// expected-error-re@*:* {{no viable conversion from returned value of type{{.*}}}}
0 commit comments