Searching for something as symmetrical as palindromes themselves, I came to this somewhat picturesque solution, that doesn't handle the empty string in a specific way, but as palindromic:
#include <string>
bool is_palindromic(const std::string& s)
{
std::string::const_iterator start = s.begin();
std::string::const_iterator end = s.end();
while (start < end) {
if (*(start++) != *(--end)) {
return false;
}
}
return true;
}
...that doesn't handle Its major drawback is the empty string in a specific way, but as palindromicredundant check for self-equality of the central char.