Use utils::ignore_return_value() for the issue #1445 dump() discard too

Addresses review feedback from @gregmarr on PR #5477: this call site was
still using the older "capture in a variable, then (void) it" pattern
from before this PR introduced utils::ignore_return_value(), instead of
the helper now used at every other discarded-nodiscard-result call site
this PR touches.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-08 20:15:31 +02:00
parent 7cb4d3284e
commit 11e91aa2c5
+2 -6
View File
@@ -641,12 +641,8 @@ TEST_CASE("regression tests 2")
s += static_cast<char>(i);
}
dump_test["1"] = s;
// dump() is nodiscard; this only checks that dumping does not throw/crash.
// A (void) cast on the call itself does not suppress GCC's warning for the
// GNU warn_unused_result attribute (unlike a real C++17 [[nodiscard]]), so
// capture the result in a variable and discard that instead.
auto dump_result = dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
(void)dump_result;
// dump() is nodiscard; this only checks that dumping does not throw/crash
utils::ignore_return_value(dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace));
}
}