【发布时间】:2019-05-29 17:10:08
【问题描述】:
void printVector(vector<int> &data){
for(auto i : data){
cout<< i << " ";
}
cout<<endl;
}
int main(){
std::vector<int> data {0,1,2,3,4,5,6,7,8,9};
vector<int> result;
result.resize(data.size());
transform(data.begin(),data.end(),result,bind(std::pow,_1,2));
return 0;
}
抛出的错误是:
stlalgo.cpp:22:61: error: no matching function for call to ‘bind(<unresolved overloaded function type>, const std::_Placeholder<1>&, int)’
如何提示bind需要使用哪个重载函数?
干杯!
【问题讨论】:
-
下面的 lambda 答案也不错,但看起来确实是同一个问题。
-
谢谢,抱歉没有出现在搜索中。
-
没问题,感谢您提出的精心编写的问题!
标签: c++