std::to_string
Use case
Build strings from numbers for logging.
Explanation
std::to_string converts numbers to std::string.
Code
#include <cstdint>
#include <iostream>
#include <string>
int main() {
int segments = 4;
size_t symbols = 127;
std::string msg = "Found " + std::to_string(segments) + " segments, " +
std::to_string(symbols) + " symbols.";
std::cout << msg << "\n";
return 0;
}
Output
$ ./src/c++11/build/std-to_string
Found 4 segments, 127 symbols.