テンプレートを使用して別のクラスメソッドにクラスメソッドを渡そうとしていますが、どのようにするかについての回答が見つかりません(C++ 11、boost ok) :私はエラーとして取得テンプレートを使用してクラスメソッドに引数として渡したクラスメソッド
class Numerical_Integrator : public Generic Integrator{
template <class T>
void integrate(void (T::*f)()){
// f(); //already without calling f() i get error
}
}
class Behavior{
void toto(){};
void evolution(){
Numerical_Integrator my_integrator;
my_integrator->integrate(this->toto};
}
:
私は、コアの問題を単純化し
error: no matching function for call to ‘Numerical_Integrator::integrate(<unresolved overloaded function type>)’this->toto);
note: no known conversion for argument 1 from ‘<unresolved overloaded function type>’ to ‘void (Behavior::*)()’
ありがとうございました。
ボーナス:引数についてはどうですか?
[Boost機能](http://www.boost.org/doc/libs/1_61_0/doc/html/function.html)および[Boost bind](http://www.boost.org/doc/) libs/1_61_0/libs/bind/doc/html/bind.html)?あるいは、[標準アルゴリズムライブラリ](http://en.cppreference.com/w/cpp/algorithm)を見て、それらがどのように "述語"を扱うかを見てください。 –
Tは何のために必要ですか?検証? – thorsan
'f(a、arg);' < - 関数に 'this'として動作するオブジェクトも必要です。 – coyotte508