[libcxx-commits] [libcxx] [libc++] Added `[[nodiscard]]` to `fstream.native_handle`, `span.at` and `in/out_ptr` (PR #167097)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 8 02:01:23 PST 2025
================
@@ -71,9 +71,11 @@ class out_ptr_t {
}
}
- _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept {
+ return std::addressof(const_cast<_Pointer&>(__p_));
+ }
- _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept
----------------
philnik777 wrote:
I don't think annotating the conversion operators makes a ton of sense. Nobody should ever call `ptr.operator void**()` and if you write `static_cast<void**>(ptr)` Clang will diagnose without the `[[nodiscard]]`.
https://github.com/llvm/llvm-project/pull/167097
More information about the libcxx-commits
mailing list