[libcxx-commits] [libcxx] [libc++][ios] Applied `[[nodiscard]]` (PR #173520)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 25 07:54:23 PST 2025


================
@@ -575,43 +575,43 @@ public:
 #    ifdef _LIBCPP_CXX03_LANG
   // Preserve the ability to compare with literal 0,
   // and implicitly convert to bool, but not implicitly convert to int.
-  _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
+  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
 #    else
-  _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
+  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
----------------
frederick-vs-ja wrote:

I believe I've written `ref.operator bool()` and `ref.operator void*()` to test them.

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


More information about the libcxx-commits mailing list