Skip to content

Instantly share code, notes, and snippets.

View M-griffin's full-sized avatar

Michael Griffin M-griffin

  • Chicago, IL
View GitHub Profile
@ranisalt
ranisalt / cast.h
Created April 11, 2016 18:54
lexical cast in C++11
/* fallback */
template<class T>
T lexical_cast(const char* str)
{
static std::istringstream ss; /* reusing has severe (positive) impact on performance */
T value;
ss.str(str);
ss >> value;
ss.clear();
return value;