Skip to content

Commit

Permalink
[dcl.attr.nodiscard] add example of nodiscard with message
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisenwave committed Aug 19, 2023
1 parent a272b7c commit ca12600
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9238,7 +9238,7 @@
\pnum
\begin{example}
\begin{codeblock}
struct [[nodiscard]] my_scopeguard { @\commentellip@ };
struct [[nodiscard("discarding guards is a bug")]] my_scopeguard { @\commentellip@ };
struct my_unique {
my_unique() = default; // does not acquire resource
[[nodiscard]] my_unique(int fd) { @\commentellip@ } // acquires resource
Expand All @@ -9249,7 +9249,7 @@
error_info enable_missile_safety_mode();
void launch_missiles();
void test_missiles() {
my_scopeguard(); // warning encouraged
my_scopeguard(); // warning encouraged; should include "discarding guards is a bug"
(void)my_scopeguard(), // warning not encouraged, cast to \keyword{void}
launch_missiles(); // comma operator, statement continues
my_unique(42); // warning encouraged
Expand Down

0 comments on commit ca12600

Please sign in to comment.