A special case
length < 3seems like a bug. A stringaais a palindrome, and one could successfully argue that a single-letter string is also a palindrome.A boolean
isPalindromeis redundant, and forces the code to test the effectively same condition twice. An early return is perfectly fine here.A traditional idiomatic (and arguably more performant) way to iterate forward is
*first++. Similarly, an idiom for iterating backwards is*--last(that also avoids subtracting 1 beforehand):last = possiblePalindrome.end(); while (first < last) { if (*first++ != *--last) { return false; } } return true;The naming is very inconsistent. I don't see the reason to spell
palindromein 3 different ways. A capitalization iniSPalendromeis also strange.