[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 20 11:52:45 PDT 2025
mordante wrote:
> If we are doing this, should we add a reason for why `std::expected` is marked as `[[nodiscard]]`? I believe it would be more helpful if a reason is supplied in the warning message for users who encountered a warning. Although libc++ doesn't seem to use `[[nodiscard("reason")]]` at all currently. Is there a policy for that internally?
AFAIK we never considered to add a reason. That feature was added in C++20, while `nodiscard` itself if C++17.
I'm not against adding a reason. FYI @philnik777 proposed to add reasons to `deprecated`.
https://github.com/llvm/llvm-project/pull/130820
More information about the libcxx-commits
mailing list