[Nicolai, if you disagree with the analysis below, please let us know] Sean Perry <[EMAIL PROTECTED]> writes:
> the code below is from Josuttis' "The C++ standard library" and I > have seen it elsewhere. It works under 2.95.4. AFAICT, the code is incorrect. > int main(int argc, char* argv[]) { > string foo = "Some Mixed Case Text"; > cout << foo << endl; > transform(foo.begin(), foo.end(), foo.begin(), tolower); The compiler can't properly resolve "tolower": The problem is that tolower is not only a function in namespace std, it is also a template (22.1.3/2). Therefore, in the call to transform, template argument deduction fails because of the ambiguity. You can fix your code in the following ways: 1. Define a wrapper function around tolower that you pass to transform. 2. Explicitly select the tolower you want to use, by writing transform(foo.begin(), foo.end(), foo.begin(), (int(*)(int))std::tolower); The cast causes, on the one hand, an explicit overload resolution in favour of the function; it also allows the compiler to properly deduce the third argument to transform. Regards, Martin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]