2 Comments

Useful for return but I also like to sometimes use it on arguments, e.g. having an argument that is used in release build but not in debug build, or when are implementing an interface and an argument is not really needed in that context. void foo(int n, [[nodiscard]] int m) -- if the compiler switch is on for treating such as an error.

Expand full comment

Hmm, interesting. I do have another post about [[nodiscard]] on constructors and types, but this is new.

Thanks for the tip.

Expand full comment