mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 07:02:11 +00:00
Add additional check to be more compliant with other casters
This commit is contained in:
parent
8c06b95492
commit
f99ff736c2
@ -266,8 +266,9 @@ template<typename T> struct optional_caster {
|
|||||||
static handle cast(T_ &&src, return_value_policy policy, handle parent) {
|
static handle cast(T_ &&src, return_value_policy policy, handle parent) {
|
||||||
if (!src)
|
if (!src)
|
||||||
return none().inc_ref();
|
return none().inc_ref();
|
||||||
using dereference_type = decltype(*std::forward<T_>(src));
|
if (!std::is_lvalue_reference<T>::value) {
|
||||||
policy = return_value_policy_override<dereference_type>::policy(policy);
|
policy = return_value_policy_override<T>::policy(policy);
|
||||||
|
}
|
||||||
return value_conv::cast(*std::forward<T_>(src), policy, parent);
|
return value_conv::cast(*std::forward<T_>(src), policy, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user