[libcxx-commits] [libcxx] [libc++] mark `std::expected` as `nodiscard` (PR #130820)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 13 11:15:54 PDT 2025


================
@@ -1354,7 +1354,7 @@ class __expected_void_base {
 
 template <class _Tp, class _Err>
   requires is_void_v<_Tp>
-class expected<_Tp, _Err> : private __expected_void_base<_Err> {
+class [[nodiscard]] expected<_Tp, _Err> : private __expected_void_base<_Err> {
----------------
mordante wrote:

Since we're adding `nodiscard` we should also review all member functions of this class. Probably all observers can be added and maybe there are other functions that should be done. (I assume the monadic operations will already work correctly.)

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


More information about the libcxx-commits mailing list