[libcxx-commits] [libcxx] [libc++] Remove [[nodiscard]] from map etc. operator[] (PR #172444)

Hans Wennborg via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 16 03:57:37 PST 2025


================
@@ -465,13 +465,13 @@ class flat_map {
   }
 
   // [flat.map.access], element access
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](const key_type& __x)
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](const key_type& __x)
----------------
zmodem wrote:

I agree that there's value in pointing people to newer APIs, but I think that falls in a different category of warnings than what nodiscard is used for, which is to flag likely bugs.

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


More information about the libcxx-commits mailing list