[libcxx-commits] [libcxx] [libc++][ios] Applied `[[nodiscard]]` (PR #173520)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 24 19:02:24 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(); }
# endif
- _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }
- _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }
----------------
frederick-vs-ja wrote:
libc++ provides several possibly non-standard <code>ios_base::*foo*</code> while _`foo`_ is supposed to be provided by `basic_ios` ([[ios.base.general]](https://eel.is/c++draft/ios.base.general), [[ios.overview]](https://eel.is/c++draft/ios.overview)). Currently I'm not marking these <code>ios_base::*foo*</code> `[[__nodiscard__]]`.
https://github.com/llvm/llvm-project/pull/173520
More information about the libcxx-commits
mailing list