[libcxx-commits] [libcxx] [libc++][locale] Applied `[[nodiscard]]` (PR #200726)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 2 19:56:05 PDT 2026


================
@@ -1018,16 +1029,16 @@ public:
     return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
   }
 
-  _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
+  [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
----------------
frederick-vs-ja wrote:

I was possibly too impetuous in touching `codecvt<char16_t, char8_t, mbstate_t>` and `codecvt<char32_t, char8_t, mbstate_t>`.

Currently, they're only provided since C++20. However, I'm unsure whether there's any plan to backport them to "pre-C++20 + `-fchar8_t`" dialects. If we won't backport them, perhaps it's better to use pretty `[[nodiscard]]` instead (and non-macro `noexcept`, in a future PR).

What do you think? @Zingam @philnik777 @ldionne

BTW, `codecvt<char16_t, char8_t, mbstate_t>` and `codecvt<char32_t, char8_t, mbstate_t>` are deprecated via [LWG3767](https://cplusplus.github.io/LWG/issue3767) (see also #105313), although we haven't implemented the deprecation. Although I think we should still test them in spite of the deprecation.

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


More information about the libcxx-commits mailing list