From ca1260083ee3e114f55b8ba6ad60079ace35c2a0 Mon Sep 17 00:00:00 2001 From: Eisenwave Date: Sun, 20 Aug 2023 00:16:37 +0200 Subject: [PATCH] [dcl.attr.nodiscard] add example of nodiscard with message --- source/declarations.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index d4302e71cd..ef49e7a8ce 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -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 @@ -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