diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index 050a6c124..de16cdf36 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -277,10 +277,12 @@ struct smart_holder_type_caster_class_hooks : smart_holder_type_caster_base_tag using holder_type = pybindit::memory::smart_holder; +#ifdef JUNK template static bool try_initialization_using_shared_from_this(holder_type *, WrappedType *, ...) { return false; } +#endif #ifdef JUNK template @@ -314,10 +316,12 @@ struct smart_holder_type_caster_class_hooks : smart_holder_type_caster_base_tag auto holder_ptr = static_cast(holder_void_ptr); new (std::addressof(v_h.holder())) holder_type(std::move(*holder_ptr)); } else { +#ifdef JUNK if (!try_initialization_using_shared_from_this( std::addressof(v_h.holder()), v_h.value_ptr(), v_h.value_ptr())) { +#endif if (inst->owned) { new (std::addressof(v_h.holder())) holder_type( holder_type::from_raw_ptr_take_ownership(v_h.value_ptr())); @@ -325,7 +329,9 @@ struct smart_holder_type_caster_class_hooks : smart_holder_type_caster_base_tag new (std::addressof(v_h.holder())) holder_type( holder_type::from_raw_ptr_unowned(v_h.value_ptr())); } +#ifdef JUNK } +#endif } v_h.holder().pointee_depends_on_holder_owner = dynamic_raw_ptr_cast_if_possible(v_h.value_ptr()) != nullptr;