boostorg / python

Boost.org python module
http://boostorg.github.io/python
Boost Software License 1.0
465 stars 201 forks source link

Expose shared_ptr to const #440

Closed MasterBe closed 2 months ago

MasterBe commented 2 months ago

Hello,

I am trying to expose std::shared_ptr<const Foo> and especially in my case I need std::vector<std::shared_ptr<const Foo>>. I tried:

  1. boost::python::implicitly_convertible<std::shared_ptr<Foo>,std::shared_ptr<const Foo>>();
  2. boost::python::register_ptr_to_python<std::shared_ptr<const Foo>>();

Both 1 and 2 don't work in jupyter notebook getting error: TypeError: No to_python (by-value) converter found for C++ type. Could you please advise on how to achieve this.