Skip to content

Commit 1246689

Browse files
authored
replaced some std::ostringstream usage with std::to_string() (#4719)
1 parent a102ff3 commit 1246689

3 files changed

Lines changed: 5 additions & 20 deletions

File tree

cli/processexecutor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ unsigned int ProcessExecutor::check()
272272
resultOfCheck = fileChecker.check(iFile->first);
273273
}
274274

275-
std::ostringstream oss;
276-
oss << resultOfCheck;
277-
pipewriter.writeEnd(oss.str());
275+
pipewriter.writeEnd(std::to_string(resultOfCheck));
278276
std::exit(EXIT_SUCCESS);
279277
}
280278

lib/templatesimplifier.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <iostream>
3333
#include <map>
3434
#include <memory>
35-
#include <sstream> // IWYU pragma: keep
3635
#include <stack>
3736
#include <utility>
3837

@@ -2422,9 +2421,7 @@ void TemplateSimplifier::simplifyTemplateArgs(Token *start, Token *end)
24222421
tok->deleteNext();
24232422
tok->deleteThis();
24242423
tok->deleteNext();
2425-
std::ostringstream sz;
2426-
sz << 1;
2427-
tok->str(sz.str());
2424+
tok->str(std::to_string(1));
24282425
again = true;
24292426
}
24302427

@@ -2433,9 +2430,7 @@ void TemplateSimplifier::simplifyTemplateArgs(Token *start, Token *end)
24332430
tok->deleteNext();
24342431
tok->deleteThis();
24352432
tok->deleteNext();
2436-
std::ostringstream ostr;
2437-
ostr << (Token::getStrLength(tok) + 1);
2438-
tok->str(ostr.str());
2433+
tok->str(std::to_string(Token::getStrLength(tok) + 1));
24392434
again = true;
24402435
}
24412436

test/testsuite.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,7 @@ bool TestFixture::assertEquals(const char * const filename, const unsigned int l
213213
bool TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const long long expected, const long long actual, const std::string &msg) const
214214
{
215215
if (expected != actual) {
216-
std::ostringstream ostr1;
217-
ostr1 << expected;
218-
std::ostringstream ostr2;
219-
ostr2 << actual;
220-
assertEquals(filename, linenr, ostr1.str(), ostr2.str(), msg);
216+
assertEquals(filename, linenr, std::to_string(expected), std::to_string(actual), msg);
221217
}
222218
return expected == actual;
223219
}
@@ -260,11 +256,7 @@ void TestFixture::todoAssertEquals(const char* const filename, const unsigned in
260256

261257
void TestFixture::todoAssertEquals(const char * const filename, const unsigned int linenr, const long long wanted, const long long current, const long long actual) const
262258
{
263-
std::ostringstream wantedStr, currentStr, actualStr;
264-
wantedStr << wanted;
265-
currentStr << current;
266-
actualStr << actual;
267-
todoAssertEquals(filename, linenr, wantedStr.str(), currentStr.str(), actualStr.str());
259+
todoAssertEquals(filename, linenr, std::to_string(wanted), std::to_string(current), std::to_string(actual));
268260
}
269261

270262
void TestFixture::assertThrow(const char * const filename, const unsigned int linenr) const

0 commit comments

Comments
 (0)