[libcxx-commits] [libcxx] [libc++] Introduce a escape hatch for the changed behavior of map and set search operations (PR #183190)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 25 04:53:36 PST 2026


================
@@ -40,8 +40,19 @@ struct __lazy_compare_result {
                         _LIBCPP_CTOR_LIFETIMEBOUND const _RHS& __rhs)
       : __comp_(__comp), __lhs_(__lhs), __rhs_(__rhs) {}
 
-  _LIBCPP_HIDE_FROM_ABI bool __less() const { return __comp_(__lhs_, __rhs_); }
-  _LIBCPP_HIDE_FROM_ABI bool __greater() const { return __comp_(__rhs_, __lhs_); }
+  _LIBCPP_HIDE_FROM_ABI bool __less() const {
+    bool __result = __comp_(__lhs_, __rhs_);
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__result ? !static_cast<bool>(__comp_(__rhs_, __lhs_)) : true,
----------------
ldionne wrote:

It's tricky, and they don't. These checks are not sufficient to really guarantee that you've got a proper SWO, but they will catch some issues. I don't think it's feasible to catch the Boost.ICL case without doing additional work (such as iterating on nodes that you would normally not look at).

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


More information about the libcxx-commits mailing list