Skip to content

Instantly share code, notes, and snippets.

@xhcnb
Created September 28, 2013 09:26
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 xhcnb/6740299 to your computer and use it in GitHub Desktop.
Save xhcnb/6740299 to your computer and use it in GitHub Desktop.
方便转换类型的模板函数
template <typename T, typename T2>
static inline T cast_to(const T2& from)
{
std::stringstream ss;
T to;
ss << from;
ss >> to;
return to;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment