开发者

How to use boost bind with member function nested in class with reference parameter?

I tried to use boost::bind inside a class method, which in turn calls another class method with reference parameter:

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

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

With this syntax, I got it compiled using VC++ 2010, but it passed string as a copy instead of reference. Then I tried to add boost_ref( _1 ) and I got compiler error said:

Error 1 error C2664: 'R boost::_mfi::mf1<R,T,A1>::operator ()<comb_str>(const U 开发者_JS百科&,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 

Update

It actually worked without the need of boost::ref. I really apologize for being careless. Thanks for all your time reading.

Any idea?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜