Created
September 28, 2013 09:26
-
-
Save xhcnb/6740299 to your computer and use it in GitHub Desktop.
方便转换类型的模板函数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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