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...

Code:
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 string::npos;
		else
			return pos - str1.begin( );
	}
It won't compile. Can anyone tell me how to make this code work?