私は次のように特定のクラス内のさまざまなメンバ関数にアクセスするために使用できるメンバ関数への「汎用」のポインタを定義しようとは:mポインタ::バリアント
class Security{
inline std::vector<double> member_function(const std::string &input_data_string){ return ... a vector<double>....;};
};
I boost :: variantを使用することで、異なる戻り値の型だけでなく異なる型のパラメータにアクセスするために使用できるメンバ関数への汎用ポインタを定義しています。
そして、これは私が得ているエラーですptr_sec_fn=&Security::member_function;
メンバ関数へのポインタを割り当てる
typedef boost::variant<std::string,double, std::vector<double>, std::vector<std::string>> (Security::*ptr_sec_fn)(boost::variant<std::string,double, std::vector<double>, std::vector<std::string>>);
:
cannot convert from 'std::vector<_Ty> (__thiscall Security::*)(const std::string &)' to 'boost::variant<T0_,T1,T2,T3> (__thiscall Security::*)(boost::variant<T0_,T1,T2,T3>)'
1> with
1> [
1> _Ty=double
1> ]
1> and
1> [
1> T0_=std::string,
1> T1=double,
1> T2=std::vector<double>,
1> T3=std::vector<std::string>
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
あなたは私がやっている識別するのに役立つてもらえここで間違っている?どうもありがとうございます。
代わりに 'boost :: function'や' std :: function'を使用することを考えましたか? – AJG85
また、 'boost :: bind'と' boost :: phoenix :: bind'を見てください。 – Smash