From 58a1b75e437c3cff526c6d6c170903cfcd862953 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 18 Jul 2024 22:31:21 -0700 Subject: [PATCH] Reinterpret `detail::type_info::default_holder` as "uses `std::unique_ptr` holder" (which is the original meaning, and compatible with the original smart_holder branch). --- include/pybind11/pybind11.h | 5 ++++- tests/test_class.cpp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index cad97eaa2..82c5423de 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1849,7 +1849,10 @@ public: record.holder_size = sizeof(holder_type); record.init_instance = init_instance; record.dealloc = dealloc; - record.default_holder = std::is_same::value; + + // A more fitting name would be uses_unique_ptr_holder. + record.default_holder = detail::is_instantiation::value; + #ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT if (detail::is_instantiation::value) { record.holder_enum_v = detail::holder_enum_t::std_unique_ptr; diff --git a/tests/test_class.cpp b/tests/test_class.cpp index e2981aca4..ba462fa85 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -211,11 +211,12 @@ TEST_SUBMODULE(class_, m) { m.def("mismatched_holder_1", []() { auto mod = py::module_::import("__main__"); py::class_>(mod, "MismatchBase1"); - py::class_(mod, "MismatchDerived1"); + py::class_, MismatchBase1>( + mod, "MismatchDerived1"); }); m.def("mismatched_holder_2", []() { auto mod = py::module_::import("__main__"); - py::class_(mod, "MismatchBase2"); + py::class_>(mod, "MismatchBase2"); py::class_, MismatchBase2>( mod, "MismatchDerived2"); });