From 7cf53ae8b4f99c0382845acf8bc63b64924dc891 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Thu, 20 May 2021 14:56:00 +0200 Subject: [PATCH] Drop constraints on casting of std::shared_ptr std::shared_ptrs can be shared across python and C++ by design. --- include/pybind11/detail/smart_holder_type_casters.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 22758e101..8c2e6387e 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -623,12 +623,6 @@ struct smart_holder_type_caster> : smart_holder_type_caster_l static constexpr auto name = _>(); 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) { - // SMART_HOLDER_WIP: IMPROVABLE: Error message. - throw cast_error("Invalid return_value_policy for shared_ptr."); - } - auto src_raw_ptr = src.get(); auto st = type_caster_base::src_and_type(src_raw_ptr); if (st.first == nullptr)