Created
June 26, 2015 12:23
-
-
Save shanehsu/a45eb3e4bc8a09145bce to your computer and use it in GitHub Desktop.
C++ to_string alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sstream> | |
template <typename T> | |
std::string to_string(const T& value) { | |
std::stringstream ss; | |
ss << value; | |
return ss.str(); | |
} | |
int i = 0; | |
std::string str = to_string(i) + "2"; // "02" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment