Use std::string for string-formatted values (#1360)

* Use `std::string` for string-formatted values

* Make `formatString` and `formatNumber` be `const`
This commit is contained in:
Sylvie
2024-03-19 02:43:18 -04:00
committed by GitHub
parent 33dd97b6a0
commit fec2266dd8
5 changed files with 90 additions and 96 deletions

View File

@@ -2690,15 +2690,13 @@ static std::string strfmt(
// Will warn after formatting is done.
str += '%';
} else {
static char buf[MAXSTRLEN + 1];
std::visit(
str.append(std::visit(
Visitor{
[&](uint32_t n) { fmt.printNumber(buf, sizeof(buf), n); },
[&](std::string const &s) { fmt.printString(buf, sizeof(buf), s.c_str()); },
[&fmt](uint32_t n) { return fmt.formatNumber(n); },
[&fmt](std::string const &s) { return fmt.formatString(s); },
},
args[argIndex]
);
str.append(buf);
));
}
argIndex++;