Team,
I have a question about the transform() algorithm. Below is a simple program takes a word and determines whether it is a palindrome (a word that is spelled the same way backwards an forwards like "madam").
The problem is with line 51. For some reason when I use the transform() algorithm, I get an error suggesting that the program can't deduce the parameter for the unary operator (in this case, the tolower() function from the cctype library). I don't understand why that is the case since I am using begin(), and
end() iterators for the string correctly (I think?).
I settled on a work around with a simple for loop, but this transform thing is
bugging me since I'm trying to learn the STL. Any insight where I am going wrong? Note: I commented transform() out since it wasn't working.
There is more than one tolower in the standard library. Even though you're not explicitly including the header that declares the other one (<locale>), standard headers are allowed to include each other arbitrarily.
You will have to learn to disambiguate between overload sets, for example using a cast:
Good stuff. I have a lot to learn still. I've never used a static_cast with a pointer to function before...let alone use it to disambiguate a function. (sigh).