fix: add cast to void to avoid gcc warning inside string_cast.cpp

It fixes this warning:
```
bench/string_cast.cpp:85:84: warning: ignoring return value of ‘std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]’, declared with attribute ‘nodiscard’ [-Wunused-result]
```
This commit is contained in:
Konstantin Akimov 2023-11-05 23:36:12 +07:00 committed by PastaPastaPasta
parent 0c26093915
commit 66432fd04e

View File

@ -59,12 +59,12 @@ static void strings_1_tostring(benchmark::Bench& bench)
static void strings_2_multi_lexical_cast(benchmark::Bench& bench) static void strings_2_multi_lexical_cast(benchmark::Bench& bench)
{ {
int i{0}; int i{0};
bench.run([&] { bench.run([&] { static_cast<void>(
boost::lexical_cast<std::string>(i) + boost::lexical_cast<std::string>(i) +
boost::lexical_cast<std::string>(i+1) + boost::lexical_cast<std::string>(i+1) +
boost::lexical_cast<std::string>(i+2) + boost::lexical_cast<std::string>(i+2) +
boost::lexical_cast<std::string>(i+3) + boost::lexical_cast<std::string>(i+3) +
boost::lexical_cast<std::string>(i+4); boost::lexical_cast<std::string>(i+4));
++i; ++i;
}); });
} }
@ -72,8 +72,8 @@ static void strings_2_multi_lexical_cast(benchmark::Bench& bench)
static void strings_2_multi_numberToString(benchmark::Bench& bench) static void strings_2_multi_numberToString(benchmark::Bench& bench)
{ {
int i{0}; int i{0};
bench.run([&] { bench.run([&] { static_cast<void>(
NumberToString(i) + NumberToString(i+1) + NumberToString(i+2) + NumberToString(i+3) + NumberToString(i+4); NumberToString(i) + NumberToString(i+1) + NumberToString(i+2) + NumberToString(i+3) + NumberToString(i+4));
++i; ++i;
}); });
} }
@ -81,8 +81,8 @@ static void strings_2_multi_numberToString(benchmark::Bench& bench)
static void strings_2_multi_tostring(benchmark::Bench& bench) static void strings_2_multi_tostring(benchmark::Bench& bench)
{ {
int i{0}; int i{0};
bench.run([&] { bench.run([&] { static_cast<void>(
ToString(i) + ToString(i+1) + ToString(i+2) + ToString(i+3) + ToString(i+4); ToString(i) + ToString(i+1) + ToString(i+2) + ToString(i+3) + ToString(i+4));
++i; ++i;
}); });
} }