Skip to content

Commit

Permalink
Making rvp::move default for py::cast with rvalue reference
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickJadoul committed May 24, 2018
1 parent 8508572 commit 7b795fe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -1608,9 +1608,11 @@ template <typename T, detail::enable_if_t<!detail::is_pyobject<T>::value, int> =
object cast(T &&value, return_value_policy policy = return_value_policy::automatic_reference,
handle parent = handle()) {
if (policy == return_value_policy::automatic)
policy = std::is_pointer<T>::value ? return_value_policy::take_ownership : return_value_policy::copy;
policy = std::is_pointer<T>::value ? return_value_policy::take_ownership :
std::is_lvalue_reference<T>::value ? return_value_policy::copy : return_value_policy::move;
else if (policy == return_value_policy::automatic_reference)
policy = std::is_pointer<T>::value ? return_value_policy::reference : return_value_policy::copy;
policy = std::is_pointer<T>::value ? return_value_policy::reference :
std::is_lvalue_reference<T>::value ? return_value_policy::copy : return_value_policy::move;
return reinterpret_steal<object>(detail::make_caster<T>::cast(std::forward<T>(value), policy, parent));
}

Expand Down

0 comments on commit 7b795fe

Please sign in to comment.