Repository navigation
|
Hi, we have a custom Is there a way to used the |
Replies: 1 comment
|
The documented custom-holder mechanism is separate from If you want to keep your pointer as the holder, the supported pattern is: // At global scope, after declaring MySharedPtr and before the bindings:
PYBIND11_DECLARE_HOLDER_TYPE(T, MySharedPtr<T>);
// Inside the module bindings:
py::class_<Widget, MySharedPtr<Widget>>(m, "Widget");This uses I would leave the macro's optional third argument at its default unless your ownership rules satisfy the documented condition for What special behavior does your pointer add, and which |
The documented custom-holder mechanism is separate from
py::smart_holder's built-in conversions. Having astd::shared_ptr-like interface doesn't by itself add your pointer type tosmart_holder.If you want to keep your pointer as the holder, the supported pattern is:
This uses
MySharedPtr<Widget>as the holder; it does not extendpy::smart_holder. The custom smart pointers documentation covers the expected.get()interface andholder_helperfor other accessors. A bound C++ type and it…