Converting an int to std::string

Amir Rachum picture Amir Rachum · Jan 12, 2011 · Viewed 257.6k times · Source

What is the shortest way, preferably inline-able, to convert an int to a string? Answers using stl and boost will be welcomed.

Answer

Yochai Timmer picture Yochai Timmer · Nov 10, 2014

You can use std::to_string in C++11

int i = 3;
std::string str = std::to_string(i);