boost::python を使用してオーバーロードされた関数を公開しようとしています。関数プロトタイプは次のとおりです。
#define FMS_lvl2_DLL_API __declspec(dllexport)
void FMS_lvl2_DLL_API write(const char *key, const char* data);
void FMS_lvl2_DLL_API write(string& key, const char* data);
void FMS_lvl2_DLL_API write(int key, const char *data);
この回答を見てきました:オーバーロードされた関数へのポインターを指定するにはどうすればよいですか?
これを行う:
BOOST_PYTHON_MODULE(python_bridge)
{
class_<FMS_logic::logical_file, boost::noncopyable>("logical_file")
.def("write", static_cast<void (*)(const char *, const char *)>( &FMS_logic::logical_file::write))
;
}
次のエラーが発生します。
error C2440: 'static_cast' : cannot convert from 'overloaded-function' to 'void (__cdecl *)(const char *,const char *)'
None of the functions with this name in scope match the target type
以下を試してください:
void (*f)(const char *, const char *) = &FMS_logic::logical_file::write;
結果:
error C2440: 'initializing' : cannot convert from 'overloaded-function' to 'void (__cdecl *)(const char *,const char *)'
None of the functions with this name in scope match the target type
何が問題で、どうすれば修正できますか?
編集 私はいくつかのことを言及するのを忘れていました:
- win-7でvs2010 proを使用しています
- write は logical_file のメンバ関数です
- FMS_logic は名前空間です