Commit f99ff736 by fatvlady Committed by Wenzel Jakob

Add additional check to be more compliant with other casters

parent 8c06b954
...@@ -266,8 +266,9 @@ template<typename T> struct optional_caster { ...@@ -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);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment