boost :: python을 사용하여 오버로드 된 함수를 노출하려고합니다. 함수 프로토 타입은 다음과 같습니다오버로드 된 함수에 대한 C++ 포인터
#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);
I'v이 대답을 볼 수 : How do I specify a pointer to an overloaded function?
이 일을 다음 시도
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
:
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))
;
}
다음과 같은 오류와 결과를 :
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
무엇을 잘못하고 해결 방법을하는거야?
내가 몇 가지 언급 잊어 편집 :
- 내가 윈 - 7
- 쓰기에 VS2010 프로를 사용하고는 logical_file의 멤버 함수는
- FMS_logic 네임 스페이스 입니다
감사합니다. FMS_logic이 네임 스페이스 인 경우 중요합니다. – elyashiv
슬프게도 Boost.Python은 함수 객체를 공식적으로 지원하지 않습니다. 함수 객체가 대부분의 영역에서 작동 할 수 있지만 가장 안전한 동작은 인스턴스 및 인수를 사용하는 비 멤버 함수를 작성한 다음 멤버 함수를 호출하는 것입니다. –