Using Boost Python & std::shared_ptr

前端 未结 4 2134
悲哀的现实
悲哀的现实 2021-02-13 06:30

I\'m trying to get Boost Python to play nicely with std::shared_ptr. Currently, I\'m receiving this error:

Traceback (most recent call last):
  File \"test.py\",         


        
4条回答
  •  囚心锁ツ
    2021-02-13 06:55

    Looks like boost::python doesn't support C++ 11 std::shared_ptr.

    If you have a look to file boost/python/converter/shared_ptr_to_python.hpp you'll find implementation of template function shared_ptr_to_python(shared_ptr const& x) for boost::shared_ptr (it explain why the code works fine for boost::shared_ptr).

    I think you have several options:

    • use boost::shared_ptr (which you trying to avoid)
    • write your implementation of shared_ptr_to_python for std::shared_ptr (IMHO the best option)
    • send request to boost::python developers to support std::shared_ptr

提交回复
热议问题