Cleaning up loaded_as_raw_ptr_unowned, loaded_as_shared_ptr.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-01-23 11:46:14 -08:00
parent c30cc404c9
commit db9af62ad8

View File

@ -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(void_ptr);
void *implicit_casted = load_impl.implicit_cast(loaded_smhldr_ptr->vptr.get());
return static_cast<T *>(implicit_casted); return static_cast<T *>(implicit_casted);
} }
}
return static_cast<T *>(loaded_smhldr_ptr->vptr.get());
}
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() {