Boost Python 1.63 (python 2.7.13)은 shared_ptr<T>
과 잘 작동합니다. 나는 C++이를 작성하는 경우 : shared_ptr과 함께 Boost Python 사용 <const T>
shared_ptr<Foo> create_shared_ptr() { return shared_ptr{...}; }
void accept_shared_ptr(const shared_ptr<Foo>& p) { }
...
class_<Foo, boost::noncopyable>("Foo", no_init); //Expose abstract class
register_ptr_to_python< shared_ptr<Foo> >();
def("create_shared_ptr", create_shared_ptr);
def("accept_shared_ptr", accept_shared_ptr);
은 그 때 나는 파이썬이 쓸 수 및 모든 작동 : 나는 시도하고
shared_ptr<const Foo>
을 포장 할 때
accept_shared_ptr(create_shared_ptr())
문제가 온다. (I이를 반환하는 라이브러리를 포장하고 있기 때문에 내가 할 필요가있다.) 다음과 같이 내가 ++ 기능을 C를 수정하는 경우 :
Boost.Python.ArgumentError: Python argument types in mod_python.accept_shared_ptr(Foo) did not match C++ signature: accept_shared_ptr(std::shared_ptr<Foo const>)
그것은이 보인다
shared_ptr<const Foo> create_shared_ptr() { return shared_ptr{...}; }
void accept_shared_ptr(const shared_ptr<const Foo>& p) { }
는 다음 나는 오류 내부는 Python Foo
에서 C++ shared_ptr<Foo>
으로의 변환을 구현하고 있지만 C++ shared_ptr<const Foo>
에는 변환을 구현하지 않습니다. 사용하기
register_ptr_to_python< shared_ptr<const Foo> >();
도움이되지 않습니다. 이 문제를 어떻게 해결할 수 있습니까?
누가 투표를 종료 하든지 : 부스트 1.62에 기반한 아래의 대답으로 문제가 해결되지 않습니다. Boost 1.62는 9 월 1 일에 공개되었고, 1.62는 11 월 2 일에 릴리스되었습니다. (https://github.com/boostorg/python/commit/97e4b34a15978ca9d7c296da2de89b78bba4e0d5). 이 커밋이 무언가를 깨뜨린 것일 수 있습니다. – Mohan