stl中bind1st和mem_fun1_ref的问题
有一简单类B和类A
struct A
{
void add_item(const B& b)
};
有B数组
vector<B> v;
A a;
for_each(v.begin(),v.end(),bind1st(mem_fun1_ref(&A::add_item),a));
由于函数mem_fun1_ref将mem_func_ptr的参数推导为const B&,
而bind1st又把绑定函数的argument_type(即上面的const B&)定义成type。
于是bind1st的函数调用参数为(argument_type& arg),导致reference to reference而编译不过了。
不修改stl的话,有什么方法?
[解决办法]
这玩意随着C++11的推出而被淘汰。用std::bind吧。
[解决办法]
void add_item(const B& b)
改为
void add_item(B b)
[解决办法]
[解决办法]
http://topic.csdn.net/u/20120411/21/f4874f13-8a32-4f3d-a801-10cc3e7bb5cb.html
[解决办法]
不能拥最新的vc编译器就上boost。要么就根本别用bind1st这破玩具
[解决办法]