diff --git a/include/pybind11/detail/smart_holder_poc.h b/include/pybind11/detail/smart_holder_poc.h index abb87827f..e83737e7b 100644 --- a/include/pybind11/detail/smart_holder_poc.h +++ b/include/pybind11/detail/smart_holder_poc.h @@ -64,8 +64,11 @@ inline int shared_from_this_status(...) { return 0; } template inline int shared_from_this_status(const std::enable_shared_from_this *ptr) { +#if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912) if (ptr->weak_from_this().lock()) return 1; return -1; +#endif + return 999; } struct smart_holder;