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 を必要とせずに機能しました。不謹慎で本当に申し訳ありません。いつもお読みいただきありがとうございます。
何か案が?