Created
November 6, 2012 11:31
-
-
Save noodles-v6/4024149 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
bool is_number(const std::string& s) | |
{ | |
std::string::const_iterator it = s.begin(); | |
while (it != s.end() && std::isdigit(*it)) ++it; | |
return !s.empty() && it == s.end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment