Efficient way to check if std::string has only spaces May 9, 2023 by Tarik if(str.find_first_not_of(' ') != std::string::npos) { // There's a non-space. }