[libcxx-commits] [libcxx] [libc++] Resolve LWG4366: Heterogeneous comparison of `expected` may be ill-formed (PR #185342)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 30 03:56:30 PDT 2026


================
@@ -446,6 +446,11 @@ class __expected_base {
   _LIBCPP_NO_UNIQUE_ADDRESS __conditional_no_unique_address<__allow_reusing_expected_tail_padding, __repr> __repr_;
 };
 
+// Helper to handle cases for LWG4366 Heterogeneous comparison of ``expected`` may be ill-formed
+// Where the comparison may produce a value that is a type that is not bool, and is implicitly
+// convertible to bool, but not explicitly.
----------------
frederick-vs-ja wrote:

Sorry for forgetting this PR before.

I think `__into_bool` can be more useful - it will also be useful for `optional` and `variant`'s comparison operators. Can we rephrase the comments to avoid mentioning LWG4366?

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


More information about the libcxx-commits mailing list