Skip to content

Commit

Permalink
Make change as suggested by @laramiel. This makes it much more obviou…
Browse files Browse the repository at this point in the history
…s that the latest implementation of `smart_holder_from_unique_ptr()` accepts all existing `return_value_policy` enum values except `copy`.
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Jul 26, 2024
1 parent 336860d commit cb6a85f
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions include/pybind11/detail/type_caster_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,8 @@ handle smart_holder_from_unique_ptr(std::unique_ptr<T, D> &&src,
return_value_policy policy,
handle parent,
const std::pair<const void *, const type_info *> &st) {
if (policy != return_value_policy::automatic
&& policy != return_value_policy::automatic_reference
&& policy != return_value_policy::take_ownership && 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.");
if (policy == return_value_policy::copy) {
throw cast_error("return_value_policy::copy is invalid for unique_ptr.");
}
if (!src) {
return none().release();
Expand Down

0 comments on commit cb6a85f

Please sign in to comment.