mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 21:25:13 +00:00
Two minor platform-specific fixes. Using static_cast instead of reinterpret_cast.
This commit is contained in:
parent
993613d9bf
commit
223283295f
@ -92,12 +92,12 @@ to_cout("LOOOK guarded_delete ctor " + std::to_string(__LINE__) + " " + __FILE__
|
||||
|
||||
template <typename T>
|
||||
inline void shd_ptr_reset(std::shared_ptr<void>& shd_ptr, void *raw_ptr, guarded_delete &&gdel) {
|
||||
shd_ptr.reset(reinterpret_cast<T *>(raw_ptr), gdel);
|
||||
shd_ptr.reset(static_cast<T *>(raw_ptr), gdel);
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<std::is_destructible<T>::value, int>::type = 0>
|
||||
inline void builtin_delete_if_destructible(void *raw_ptr) {
|
||||
delete reinterpret_cast<T *>(raw_ptr);
|
||||
delete static_cast<T *>(raw_ptr);
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<!std::is_destructible<T>::value, int>::type = 0>
|
||||
@ -115,7 +115,7 @@ guarded_delete make_guarded_builtin_delete(bool armed_flag) {
|
||||
|
||||
template <typename T, typename D>
|
||||
inline void custom_delete(void *raw_ptr) {
|
||||
D()(reinterpret_cast<T *>(raw_ptr));
|
||||
D()(static_cast<T *>(raw_ptr));
|
||||
}
|
||||
|
||||
template <typename T, typename D>
|
||||
@ -245,7 +245,7 @@ to_cout("LOOOK smart_holder from_raw_ptr_unowned " + std::to_string(__LINE__) +
|
||||
|
||||
template <typename T>
|
||||
T *as_raw_ptr_unowned() const {
|
||||
to_cout("LOOOK smart_holder as_raw_ptr_unowned PTR" + std::to_string((unsigned long) vptr.get()) + " " + std::to_string(__LINE__) + " " + __FILE__);
|
||||
to_cout("LOOOK smart_holder as_raw_ptr_unowned " + std::to_string(__LINE__) + " " + __FILE__);
|
||||
return static_cast<T *>(vptr.get());
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ struct RescuingDeleter {
|
||||
explicit RescuingDeleter(PyWrapper *pyw) : pyw{pyw} {}
|
||||
void operator()(ToBeWrapped *raw_ptr) {
|
||||
if (pyw->self.get() != nullptr) {
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1912
|
||||
#if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
|
||||
assert(raw_ptr->weak_from_this().expired()); // CRITICAL
|
||||
#endif
|
||||
pyw->wobj = std::shared_ptr<ToBeWrapped>(raw_ptr, *this);
|
||||
|
Loading…
Reference in New Issue
Block a user