Drop constraints on casting of std::shared_ptr

std::shared_ptrs can be shared across python and C++ by design.
This commit is contained in:
Robert Haschke 2021-05-20 14:56:00 +02:00
parent 29e46381e4
commit 7cf53ae8b4

View File

@ -623,12 +623,6 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
static constexpr auto name = _<std::shared_ptr<T>>(); static constexpr auto name = _<std::shared_ptr<T>>();
static handle cast(const std::shared_ptr<T> &src, return_value_policy policy, handle parent) { static handle cast(const std::shared_ptr<T> &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 src_raw_ptr = src.get();
auto st = type_caster_base<T>::src_and_type(src_raw_ptr); auto st = type_caster_base<T>::src_and_type(src_raw_ptr);
if (st.first == nullptr) if (st.first == nullptr)