Boost Python No to_python for std::unique_ptr

雨燕双飞 提交于 2019-12-23 03:43:13

问题


I have a problem with boost.python that I can't solve. I tried to expose a class including a function that returns a std::unique_ptr.

The signature looks like: std::unique_ptr<MyClass> myFunc() const;

I exposed the function and got the following error when calling myFunc() in python:

TypeError: No to_python (by-value) converter found for C++ type: std::unique_ptr<MyClass, std::default_delete<MyClass> >

I tried to solve the error by also exposing the pointer with the following code:

class_<std::unique_ptr<MyClass, std::default_delete<MyClass> >, boost::noncopyable ("MyClass", init<>());

Which compiles without any errors, but still produces the same error.

Am I missing something?

来源:https://stackoverflow.com/questions/20590205/boost-python-no-to-python-for-stdunique-ptr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!