mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
upd: [imp] add nodiscard for fmt
This commit is contained in:
parent
73443ee0a6
commit
a2dfde6a63
@ -11,7 +11,7 @@ namespace {
|
|||||||
|
|
||||||
void imp_fmt_string(benchmark::State &state) {
|
void imp_fmt_string(benchmark::State &state) {
|
||||||
for (auto _ : 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) {
|
void imp_fmt_int(benchmark::State &state) {
|
||||||
for (auto _ : 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) {
|
void imp_fmt_float(benchmark::State &state) {
|
||||||
for (auto _ : 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) {
|
void imp_fmt_chrono(benchmark::State &state) {
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
imp::fmt(std::chrono::system_clock::now());
|
std::ignore = imp::fmt(std::chrono::system_clock::now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,12 +52,12 @@ auto spec(char const (&fstr)[N]) noexcept {
|
|||||||
/// @brief String formatting function.
|
/// @brief String formatting function.
|
||||||
|
|
||||||
template <typename A>
|
template <typename A>
|
||||||
std::string fmt(A &&a) {
|
LIBIMP_NODISCARD std::string fmt(A &&a) {
|
||||||
return fmt_to_string(std::forward<A>(a));
|
return fmt_to_string(std::forward<A>(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename A1, typename... 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)));
|
std::string joined(fmt(std::forward<A1>(a1)));
|
||||||
LIBIMP_UNUSED auto unfold = {
|
LIBIMP_UNUSED auto unfold = {
|
||||||
joined.append(fmt_to_string(std::forward<A>(args)))...
|
joined.append(fmt_to_string(std::forward<A>(args)))...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user