Możesz do tego użyć algorytmu std::all_of:
std::string text = ""; const bool only_spaces = std::all_of(begin(text), end(text), [](char symbol) { return symbol == ' '; });
#EDIT Jeszcze sposób dla wszystkich białych znaków:
std::string text = ""; const bool only_space = std::all_of(begin(text), end(text), static_cast<int(&)(int)>(std::isspace));