From be60fc52a448a0c1ab8088481a2a78a5662f13b9 Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Sat, 19 Jun 2021 16:40:51 +0200 Subject: [PATCH] Allow move policy in smart holder caster for shared_ptr --- include/pybind11/detail/smart_holder_type_casters.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 50c4b64e9..30709b0e8 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -628,9 +628,12 @@ struct smart_holder_type_caster> : smart_holder_type_caster_l static handle cast(const std::shared_ptr &src, return_value_policy policy, handle parent) { if (policy != return_value_policy::automatic - && policy != return_value_policy::reference_internal + && policy != return_value_policy::automatic_reference + // (but not take_ownership) && policy != return_value_policy::copy - && policy != return_value_policy::automatic_reference) { + && policy != return_value_policy::move + // (but not reference) + && policy != return_value_policy::reference_internal) { // SMART_HOLDER_WIP: IMPROVABLE: Error message. throw cast_error("Invalid return_value_policy for shared_ptr."); }