Determine if a std::string has all of the same character
You could simply use find_first_not_of 

bool string_has_all_of_the_same_chars(const std::string&amp; s) {
    return s.find_first_not_of(s[0]) == std::string::npos;
}


Update:

This works only, when the string is not empty. A complete version would also test empty 

bool string_has_all_of_the_same_chars(const std::string&amp; s) {
    return s.empty() || s.find_first_not_of(s[0]) == std::string::npos;
}


Instead of s[0], one could also use s.front() or *s.begin().