std::search isn't working!
I'm trying to do a case insensitive comparison on two strings. I found this piece of code online but since I've never used std::search before, I don't know how to make the predicate part work. Here's what I've got so far...
It won't compile. Can anyone tell me how to make this code work?
bool ci_equal(char ch1, char ch2)
return toupper((unsigned char)ch1) == toupper((unsigned char)ch2);
size_t ci_find(const string& str1, const string& str2)
string::const_iterator pos = search(str1.begin( ), str1.end( ), str2.begin( ), str2.end( ), ci_equal()); //PROBLEM IN THIS LINE!
if (pos == str1.end( ))
return pos - str1.begin( );