Skip to content

Instantly share code, notes, and snippets.

@jorgemsrs
Created June 9, 2012 21:49
Show Gist options
  • Save jorgemsrs/2902709 to your computer and use it in GitHub Desktop.
Save jorgemsrs/2902709 to your computer and use it in GitHub Desktop.
C++ template
/**
* Templated method that uses a underlying stringstream to perform
* conversions from string references.
*/
template<class T>
static T fromString(const std::string &s) {
std::istringstream stream(s);
T t;
stream >> t;
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment