The use of std::toupper (as opposed to the global toupper) is problematic in this case, though the exact reason eludes me at the moment. (Type mismatch? I know this has been discussed before.) Josuttis suggests just defining a function that compares characters without regard for case, and then use say, equal(), e.g.,
Code:
bool noCaseEqualChar(char lhs, char rhs)
{
return std::toupper(lhs) == std::toupper(rhs);
}
bool noCaseEqual(const std::string& lhs, const std::string& rhs)
{
return lhs.size() == rhs.size()
&& std::equal(lhs.begin(), lhs.end(), rhs.begin(), noCaseEqualChar);
}
We could use function object template classes instead and thus not have to resort to the different function names.