[libcxx-commits] [libcxx] [libc++] Make `flat_(multi)map`'s iterators require `operator<=>` (PR #131290)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 22 05:25:22 PDT 2025


================
@@ -139,9 +141,12 @@ struct __key_value_iterator {
     return !(__x < __y);
   }
 
-  _LIBCPP_HIDE_FROM_ABI friend auto operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y)
-    requires three_way_comparable<__key_iterator>
-  {
+  _LIBCPP_HIDE_FROM_ABI friend strong_ordering
+  operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y) {
----------------
mordante wrote:

The difference is observable. An explicit instantiation of a `flat_map` that uses a type not providing a three-way comparable iterator will fail with a static assert, but compiles with a requires.
https://godbolt.org/z/Tbn4nc433

I have not checked whether `flat_map` has other mandates that causes the code to be ill-formed anyway.

https://github.com/llvm/llvm-project/pull/131290


More information about the libcxx-commits mailing list