For C ++ 11, you can check if a line is a space using std::all_of and isspace (isspace checks for spaces, tabs, new line, vertical tab, feed and carriage return:
std::string str = " "; std::all_of(str.begin(), str.end(), isspace); //this returns true in this case
if you really only want to check the character space:
std::all_of(str.begin(), str.end(), [](const char& c) { return c == ' '; });
Jonathan.
source share