Annotate fmt::format and fmt::formatted_size as [[nodiscard]]

This prevents accidentally writing fmt::format when fmt::print was
intended. Other than running tests, there's not a good use case for
discarding the formatted output.
This commit is contained in:
Florin Iucha
2021-11-25 07:30:30 -08:00
committed by Victor Zverovich
parent 5abe9e8266
commit 491ba2dda5
7 changed files with 196 additions and 185 deletions
+2 -2
View File
@@ -902,10 +902,10 @@ TEST(core_test, adl) {
if (fmt::detail::const_check(true)) return;
auto s = adl_test::string();
char buf[10];
fmt::format("{}", s);
(void)fmt::format("{}", s);
fmt::format_to(buf, "{}", s);
fmt::format_to_n(buf, 10, "{}", s);
fmt::formatted_size("{}", s);
(void)fmt::formatted_size("{}", s);
fmt::print("{}", s);
fmt::print(stdout, "{}", s);
}