下面这段代码会报错:报错信息为error: no matching function for call to ‘ptr_fun(<unresolved overloaded function type>)
#include <algorithm>
#include <cctype>#include <string>
const std::string StrToUpper(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(),std::ptr_fun(std::toupper));
return s;
}
Solution
Explicitly add the template parameters:
#include <algorithm> |