如何使用与参数参数嵌套在类中的成员函数的boost绑定?

时间:2011-01-21 21:01:41

标签: c++ boost boost-bind

我尝试在类方法中使用boost::bind,后者又使用引用参数调用另一个类方法:

void some_method() {   
     for_each( con.begin(), con.end(), boost::bind( &comb_str::dfs, this, _1 ) );
}

void dfs( string& str ) {
... 
}

使用这种语法,我使用VC ++ 2010编译它,但它将string作为副本而不是引用传递。然后我尝试添加boost_ref( _1 ),我得到编译器错误说:

Error 1 error C2664: 'R boost::_mfi::mf1<R,T,A1>::operator ()<comb_str>(const U &,A1) const' : cannot convert parameter 2 from 'boost::arg<I>' to 'std::basic_string<_Elem,_Traits,_Ax> ' c:\program files\boost\boost_1_44\boost\bind\bind.hpp 313 1 

更新
它实际上没有boost :: ref的需要。我为粗心大意道歉。感谢你所有的时间阅读。

有什么想法吗?

0 个答案:

没有答案
相关问题