mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
Support std::shared_ptr holder type out of the box
With this there is no more need for manual user declarations like `PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)`. Existing ones will still compile without error -- they will just be ignored silently. Resolves #446.
This commit is contained in:
@@ -82,8 +82,9 @@ private:
|
||||
};
|
||||
|
||||
/// Make pybind aware of the ref-counted wrapper type (s)
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, ref<T>);
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, ref<T>); // Required for custom holder type
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>); // Not required any more for std::shared_ptr,
|
||||
// but it should compile without error
|
||||
|
||||
Object *make_object_1() { return new MyObject1(1); }
|
||||
ref<Object> make_object_2() { return new MyObject1(2); }
|
||||
|
||||
Reference in New Issue
Block a user