Skip to content

Commit cb6a85f

Browse files
committed
Make change as suggested by @laramiel. This makes it much more obvious that the latest implementation of smart_holder_from_unique_ptr() accepts all existing return_value_policy enum values except copy.
1 parent 336860d commit cb6a85f

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

include/pybind11/detail/type_caster_base.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,8 @@ handle smart_holder_from_unique_ptr(std::unique_ptr<T, D> &&src,
528528
return_value_policy policy,
529529
handle parent,
530530
const std::pair<const void *, const type_info *> &st) {
531-
if (policy != return_value_policy::automatic
532-
&& policy != return_value_policy::automatic_reference
533-
&& policy != return_value_policy::take_ownership && policy != return_value_policy::move
534-
&& policy != return_value_policy::reference
535-
&& policy != return_value_policy::reference_internal) {
536-
// SMART_HOLDER_WIP: IMPROVABLE: Error message.
537-
throw cast_error("Invalid return_value_policy for unique_ptr.");
531+
if (policy == return_value_policy::copy) {
532+
throw cast_error("return_value_policy::copy is invalid for unique_ptr.");
538533
}
539534
if (!src) {
540535
return none().release();

0 commit comments

Comments
 (0)