From f99ff736c27f2209b66ca367b6ebe14c58c771f3 Mon Sep 17 00:00:00 2001 From: fatvlady Date: Mon, 29 Jun 2020 20:52:35 +0300 Subject: [PATCH] Add additional check to be more compliant with other casters --- include/pybind11/stl.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 77da1336..b5f7e723 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -266,8 +266,9 @@ template struct optional_caster { static handle cast(T_ &&src, return_value_policy policy, handle parent) { if (!src) return none().inc_ref(); - using dereference_type = decltype(*std::forward(src)); - policy = return_value_policy_override::policy(policy); + if (!std::is_lvalue_reference::value) { + policy = return_value_policy_override::policy(policy); + } return value_conv::cast(*std::forward(src), policy, parent); }