您的位置:首页 > 其它

error: no matching function for call to ‘ptr_fun(<unresolved overloaded function type>)’

2011-01-04 10:31 1041 查看
下面这段代码会报错:报错信息为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>
#include <cctype>
#include <string>

//From http://www.richelbilderbeek.nl/CppStrToUpper.htm const std::string StrToUpper(std::string s)
{
std::transform(s.begin(), s.end(), s.begin(),std::ptr_fun<int,int>(std::toupper));
return s;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐