Skip to content

Instantly share code, notes, and snippets.

@stfnm
Created August 1, 2012 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stfnm/3224452 to your computer and use it in GitHub Desktop.
Save stfnm/3224452 to your computer and use it in GitHub Desktop.
template<typename TO, typename FROM>
TO lexi_cast(const FROM& from) {
std::stringstream s;
TO to;
s << from;
s >> to;
return to;
}
// e.g.:
// std::string s = lexi_cast<std::string, int>(23);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment