Open
Description
I am trying to wrap a C++ class of the following type. The class has a protected destructor but should be containable in a shared_ptr due to the public inheritance from enable_shared_from_this. However, the pybind code produces an error becuase of the protected destructor.
The code also throws an error if I try to use the following pybind wrapper:
py::class_<MyClass, std::unique_ptr<MyClass, py::nodelete>> clsMyClass(mod, "MyClass");
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace py = pybind11;
namespace {
class MyClass : public std::enable_shared_from_this<MyClass> {
protected:
MyClass() {}
~MyClass() {}
};
PYBIND11_MODULE(myclass, mod) {
py::class_<MyClass, std::shared_ptr<MyClass>> clsMyClass(mod, "MyClass");
}
}
Metadata
Metadata
Assignees
Labels
No labels