From 124668979cb3e0989ae913956cad3e464c711d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 16 Jan 2023 22:05:33 +0100 Subject: [PATCH] replaced some `std::ostringstream` usage with `std::to_string()` (#4719) --- cli/processexecutor.cpp | 4 +--- lib/templatesimplifier.cpp | 9 ++------- test/testsuite.cpp | 12 ++---------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index fc040dca8..fb0f1f607 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -272,9 +272,7 @@ unsigned int ProcessExecutor::check() resultOfCheck = fileChecker.check(iFile->first); } - std::ostringstream oss; - oss << resultOfCheck; - pipewriter.writeEnd(oss.str()); + pipewriter.writeEnd(std::to_string(resultOfCheck)); std::exit(EXIT_SUCCESS); } diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 5ad009eda..4cb9e18f1 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -32,7 +32,6 @@ #include #include #include -#include // IWYU pragma: keep #include #include @@ -2422,9 +2421,7 @@ void TemplateSimplifier::simplifyTemplateArgs(Token *start, Token *end) tok->deleteNext(); tok->deleteThis(); tok->deleteNext(); - std::ostringstream sz; - sz << 1; - tok->str(sz.str()); + tok->str(std::to_string(1)); again = true; } @@ -2433,9 +2430,7 @@ void TemplateSimplifier::simplifyTemplateArgs(Token *start, Token *end) tok->deleteNext(); tok->deleteThis(); tok->deleteNext(); - std::ostringstream ostr; - ostr << (Token::getStrLength(tok) + 1); - tok->str(ostr.str()); + tok->str(std::to_string(Token::getStrLength(tok) + 1)); again = true; } diff --git a/test/testsuite.cpp b/test/testsuite.cpp index 42363fde8..64e818e00 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -213,11 +213,7 @@ bool TestFixture::assertEquals(const char * const filename, const unsigned int l bool TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const long long expected, const long long actual, const std::string &msg) const { if (expected != actual) { - std::ostringstream ostr1; - ostr1 << expected; - std::ostringstream ostr2; - ostr2 << actual; - assertEquals(filename, linenr, ostr1.str(), ostr2.str(), msg); + assertEquals(filename, linenr, std::to_string(expected), std::to_string(actual), msg); } return expected == actual; } @@ -260,11 +256,7 @@ void TestFixture::todoAssertEquals(const char* const filename, const unsigned in void TestFixture::todoAssertEquals(const char * const filename, const unsigned int linenr, const long long wanted, const long long current, const long long actual) const { - std::ostringstream wantedStr, currentStr, actualStr; - wantedStr << wanted; - currentStr << current; - actualStr << actual; - todoAssertEquals(filename, linenr, wantedStr.str(), currentStr.str(), actualStr.str()); + todoAssertEquals(filename, linenr, std::to_string(wanted), std::to_string(current), std::to_string(actual)); } void TestFixture::assertThrow(const char * const filename, const unsigned int linenr) const