Skip to content

Instantly share code, notes, and snippets.

@shanehsu
Created June 26, 2015 12:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanehsu/a45eb3e4bc8a09145bce to your computer and use it in GitHub Desktop.
Save shanehsu/a45eb3e4bc8a09145bce to your computer and use it in GitHub Desktop.
C++ to_string alternative
#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