From 63044cc19950acd6ffe5390e1a25f6973280fb4c Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 12 Jul 2024 08:26:34 -0700 Subject: [PATCH] Bring in `default_holder_type` from smart_holder branch including using it in pybind11/stl_bind.h --- include/pybind11/cast.h | 6 ++++++ include/pybind11/pybind11.h | 3 +++ include/pybind11/stl_bind.h | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 893c25cc0..b444c83ca 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1111,6 +1111,12 @@ template struct is_holder_type : std::is_base_of, detail::type_caster> {}; +// Specializations for always-supported holders: +template +struct is_holder_type> : std::true_type {}; +template +struct is_holder_type : std::true_type {}; + #ifdef PYBIND11_DISABLE_HANDLE_TYPE_NAME_DEFAULT_IMPLEMENTATION // See PR #4888 // This leads to compilation errors if a specialization is missing. diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 71220e4f1..ead4006ef 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1775,6 +1775,9 @@ struct property_cpp_function< } }; +template +using default_holder_type = pybindit::memory::smart_holder; + template class class_ : public detail::generic_type { template diff --git a/include/pybind11/stl_bind.h b/include/pybind11/stl_bind.h index 66c452ea7..a04e16864 100644 --- a/include/pybind11/stl_bind.h +++ b/include/pybind11/stl_bind.h @@ -487,7 +487,7 @@ PYBIND11_NAMESPACE_END(detail) // // std::vector // -template , typename... Args> +template , typename... Args> class_ bind_vector(handle scope, std::string const &name, Args &&...args) { using Class_ = class_; @@ -696,7 +696,7 @@ struct ItemsViewImpl : public detail::items_view { PYBIND11_NAMESPACE_END(detail) -template , typename... Args> +template , typename... Args> class_ bind_map(handle scope, const std::string &name, Args &&...args) { using KeyType = typename Map::key_type; using MappedType = typename Map::mapped_type;