From 17c0354050ad377eef38cbe57453e24a79989c3f Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 3 Jul 2024 10:30:14 -0700 Subject: [PATCH] `copyable_holder_caster>`: split `load_value_shared_ptr()`, `load_value_smart_holder()` (the latter just throws right now) --- include/pybind11/cast.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index aca6ce8b1..34d7178a3 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -867,13 +867,9 @@ public: protected: friend class type_caster_generic; - void check_holder_compat() { - if (typeinfo->default_holder) { - throw cast_error("Unable to load a custom holder type from a default-holder instance"); - } - } + void check_holder_compat() {} - bool load_value(value_and_holder &&v_h) { + bool load_value_shared_ptr(value_and_holder &&v_h) { if (v_h.holder_constructed()) { value = v_h.value_ptr(); holder = v_h.template holder>(); @@ -889,6 +885,17 @@ protected: #endif } + bool load_value_smart_holder(value_and_holder && /*v_h*/) { + throw std::runtime_error("BAKEIN_WIP load_value_smart_holder"); + } + + bool load_value(value_and_holder &&v_h) { + if (typeinfo->default_holder) { + return load_value_smart_holder(std::move(v_h)); + } + return load_value_shared_ptr(std::move(v_h)); + } + template , detail::enable_if_t::value, int> = 0> bool try_implicit_casts(handle, bool) {