mirror of
https://github.com/nlohmann/json.git
synced 2026-09-09 01:37:57 +00:00
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:
@@ -641,12 +641,8 @@ TEST_CASE("regression tests 2")
|
|||||||
s += static_cast<char>(i);
|
s += static_cast<char>(i);
|
||||||
}
|
}
|
||||||
dump_test["1"] = s;
|
dump_test["1"] = s;
|
||||||
// dump() is nodiscard; this only checks that dumping does not throw/crash.
|
// 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
|
utils::ignore_return_value(dump_test.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace));
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user