static const char *szSpaceChars = " \t\r\n"; bool is_std_string_all_space(const std::string &str) { if (str.empty()) return true; return str.find_first_not_of(szSpaceChars) == std::string::npos; }
Programming Tips - What's the best way to check of a std::string is all space characters?
Date: 2008jun27
Language: C/C++
Q. What's the best way to check of a std::string is all space characters?
A. This function does it nicely.