[libcxx-commits] [libcxx] [libc++][RFC] Document when to apply [[nodiscard]] (PR #84000)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 9 05:15:20 PST 2024


mordante wrote:

> The whole point of my [P3122R0](https://wg21.link/p3122r0) paper is that I think implementations should make their own decisions about where to use nodiscard. The standard should do no more than make some vague recommendations, and definitely _not_ try to standardize where it should be used (or even worse, standardize where it should not be used).

True, but your paper has some nice suggestions and when that becomes recommended practice I would like to see that as minimal set in our documentation. After which we can look whether more places would be useful to have nodiscards. 

> So I am very pleased to see this change and the start of a discussion. Please don't wait for WG21 to specify nodiscard on individual functions or on some minimal "low effort" set of functions.

At the moment all our nodiscards not specified in the Standard can be disabled. The disabling mechanism  tests all occurrences. Depending on the outcome in discussion Tokyo I want to discuss internally whether we want to keep testing all disabling occurrences or not. (We already removed the documentation for them.) 

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


More information about the libcxx-commits mailing list