upd: [imp] add nodiscard for fmt

This commit is contained in:
mutouyun 2022-12-03 16:29:39 +08:00
parent 73443ee0a6
commit a2dfde6a63
2 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ namespace {
void imp_fmt_string(benchmark::State &state) {
for (auto _ : state) {
imp::fmt("hello world. hello world. hello world. hello world. hello world.");
std::ignore = imp::fmt("hello world. hello world. hello world. hello world. hello world.");
}
}
@ -23,7 +23,7 @@ void fmt_format_string(benchmark::State &state) {
void imp_fmt_int(benchmark::State &state) {
for (auto _ : state) {
imp::fmt(654321);
std::ignore = imp::fmt(654321);
}
}
@ -35,7 +35,7 @@ void fmt_format_int(benchmark::State &state) {
void imp_fmt_float(benchmark::State &state) {
for (auto _ : state) {
imp::fmt(654.321);
std::ignore = imp::fmt(654.321);
}
}
@ -47,7 +47,7 @@ void fmt_format_float(benchmark::State &state) {
void imp_fmt_chrono(benchmark::State &state) {
for (auto _ : state) {
imp::fmt(std::chrono::system_clock::now());
std::ignore = imp::fmt(std::chrono::system_clock::now());
}
}

View File

@ -52,12 +52,12 @@ auto spec(char const (&fstr)[N]) noexcept {
/// @brief String formatting function.
template <typename A>
std::string fmt(A &&a) {
LIBIMP_NODISCARD std::string fmt(A &&a) {
return fmt_to_string(std::forward<A>(a));
}
template <typename A1, typename... A>
std::string fmt(A1 &&a1, A &&...args) {
LIBIMP_NODISCARD std::string fmt(A1 &&a1, A &&...args) {
std::string joined(fmt(std::forward<A1>(a1)));
LIBIMP_UNUSED auto unfold = {
joined.append(fmt_to_string(std::forward<A>(args)))...