mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-20 01:42:37 +00:00
Call new load_helper.get_void_ptr_or_nullptr() instead of calling type_caster_generic::load_value() in shared_ptr and unique_ptr casters.
This commit is contained in:
parent
36bbac1b47
commit
c6a87e8897
@ -903,7 +903,7 @@ protected:
|
||||
void load_value(value_and_holder &&v_h) {
|
||||
if (typeinfo->default_holder) {
|
||||
sh_load_helper.loaded_v_h = v_h;
|
||||
type_caster_generic::load_value(std::move(v_h)); // NOLINT(performance-move-const-arg)
|
||||
value = sh_load_helper.get_void_ptr_or_nullptr();
|
||||
return;
|
||||
}
|
||||
if (v_h.holder_constructed()) {
|
||||
@ -1028,7 +1028,7 @@ public:
|
||||
if (typeinfo->default_holder) {
|
||||
sh_load_helper.loaded_v_h = v_h;
|
||||
sh_load_helper.loaded_v_h.type = get_type_info(typeid(type));
|
||||
type_caster_generic::load_value(std::move(v_h)); // NOLINT(performance-move-const-arg)
|
||||
value = sh_load_helper.get_void_ptr_or_nullptr();
|
||||
return;
|
||||
}
|
||||
throw std::runtime_error("BAKEIN_WIP: What is the best behavior here (load_value)?");
|
||||
|
@ -617,6 +617,16 @@ printf("\nLOOOK throw(Python instance was disowned.)\n"); fflush(stdout); // NO
|
||||
throw value_error("Python instance is currently owned by a std::shared_ptr.");
|
||||
}
|
||||
}
|
||||
|
||||
void *get_void_ptr_or_nullptr() const {
|
||||
if (have_holder()) {
|
||||
auto &hld = holder();
|
||||
if (hld.is_populated && hld.has_pointee()) {
|
||||
return hld.template as_raw_ptr_unowned<void>();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename D>
|
||||
|
Loading…
Reference in New Issue
Block a user