From afdb00bc2fcf0f2c1bddb9404ebed11d5879e0ee Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Thu, 18 Mar 2021 00:54:13 +0100 Subject: [PATCH 1/2] Allow loading of const unique_ptr& --- include/pybind11/cast.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 64d590dbf8..497d48ca28 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -789,6 +789,10 @@ struct move_only_holder_caster : type_caster_base { auto *ptr = holder_helper::get(src); return type_caster_base::cast_holder(ptr, holder_erased(std::addressof(src))); } + static handle cast(const holder_type& src, return_value_policy policy, handle parent) { + const auto *ptr = holder_helper::get(src); + return type_caster_base::cast_holder(ptr, holder_erased(std::addressof(src))); + } // Disable these? // explicit operator type*() { return this->value; } From f0e3bcc34d1ed6ac610a556e504478a2223ed81a Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Thu, 18 Mar 2021 08:01:11 +0100 Subject: [PATCH 2/2] fixup! Allow loading of const unique_ptr& Fix unused parameters. --- include/pybind11/cast.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 497d48ca28..7623e37dfa 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -789,7 +789,7 @@ struct move_only_holder_caster : type_caster_base { auto *ptr = holder_helper::get(src); return type_caster_base::cast_holder(ptr, holder_erased(std::addressof(src))); } - static handle cast(const holder_type& src, return_value_policy policy, handle parent) { + static handle cast(const holder_type& src, return_value_policy, handle) { const auto *ptr = holder_helper::get(src); return type_caster_base::cast_holder(ptr, holder_erased(std::addressof(src))); }