I've wrote comparator functional object for std::map
for comparing string without case sensitivity.
class CaseInsensitiveCmp
{
public:
bool operator() (const std::string& op1, const std::string& op2) const
{
std::string op1low(op1.size(),'c'), op2low(op2.size(),'c');
std::transform(op1.begin(), op1.end(),op1low.begin(),::tolower);
std::transform(op2.begin(), op2.end(),op2low.begin(),::tolower);
return op1low<op2low;
}
};
The problem is, that if the member function (operator() ) is not const function i.e.
bool operator() (const std::string& op1, const std::string& op2);
The compiler XLC compiler generates en error
CaseInsensitiveCmp::operator()(const std::string &, const std::string &)" is not a viable candidate.
Can anyone refer to any point in c++ standard that says that comparison functional object member function must be const?