mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-07 17:32:00 +00:00
Cleaning up loaded_as_raw_ptr_unowned, loaded_as_shared_ptr.
This commit is contained in:
parent
c30cc404c9
commit
db9af62ad8
@ -232,23 +232,18 @@ struct smart_holder_type_caster_load {
|
|||||||
}
|
}
|
||||||
|
|
||||||
T *loaded_as_raw_ptr_unowned() {
|
T *loaded_as_raw_ptr_unowned() {
|
||||||
// BYPASSES smart_holder type checking completely.
|
void *void_ptr = loaded_smhldr_ptr->as_raw_ptr_unowned<void>();
|
||||||
if (load_impl.loaded_v_h_cpptype != nullptr) {
|
if (load_impl.loaded_v_h_cpptype == nullptr || load_impl.reinterpret_cast_deemed_ok
|
||||||
if (load_impl.reinterpret_cast_deemed_ok) {
|
|| load_impl.implicit_cast == nullptr) {
|
||||||
return static_cast<T *>(loaded_smhldr_ptr->vptr.get());
|
return static_cast<T *>(void_ptr);
|
||||||
}
|
|
||||||
if (load_impl.implicit_cast != nullptr) {
|
|
||||||
void *implicit_casted = load_impl.implicit_cast(loaded_smhldr_ptr->vptr.get());
|
|
||||||
return static_cast<T *>(implicit_casted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return static_cast<T *>(loaded_smhldr_ptr->vptr.get());
|
void *implicit_casted = load_impl.implicit_cast(void_ptr);
|
||||||
|
return static_cast<T *>(implicit_casted);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<T> loaded_as_shared_ptr() {
|
std::shared_ptr<T> loaded_as_shared_ptr() {
|
||||||
T *raw_ptr = loaded_as_raw_ptr_unowned();
|
T *raw_ptr = loaded_as_raw_ptr_unowned();
|
||||||
// BYPASSES smart_holder shared_ptr tracking completely.
|
return std::shared_ptr<T>(loaded_smhldr_ptr->as_shared_ptr<void>(), raw_ptr);
|
||||||
return std::shared_ptr<T>(loaded_smhldr_ptr->vptr, raw_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<T> loaded_as_unique_ptr() {
|
std::unique_ptr<T> loaded_as_unique_ptr() {
|
||||||
|
Loading…
Reference in New Issue
Block a user