From 12f384bcbb5328fb3ad2f824bfee2e9ee8c01cd7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 14 Jul 2024 23:52:54 -0700 Subject: [PATCH] `smart_holder_from_unique_ptr`: also accept `return_value_policy::reference` There are no strong reasons for accepting or rejecting `return_value_policy::reference`. Accepting to accommodate existing use cases in the wild. --- include/pybind11/detail/type_caster_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index c13261538..04e87c24c 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -635,8 +635,8 @@ handle smart_holder_from_unique_ptr(std::unique_ptr &&src, const std::pair &st) { if (policy != return_value_policy::automatic && policy != return_value_policy::automatic_reference - && policy != return_value_policy::reference_internal - && policy != return_value_policy::move) { + && policy != return_value_policy::move && policy != return_value_policy::reference + && policy != return_value_policy::reference_internal) { // SMART_HOLDER_WIP: IMPROVABLE: Error message. throw cast_error("Invalid return_value_policy for unique_ptr."); }