From 556277d689f64f2b4910f5ace1ed1cb5a793726c Mon Sep 17 00:00:00 2001 From: fatvlady Date: Sat, 14 Mar 2020 15:20:04 +0200 Subject: [PATCH] Fix optional dereference type deduction --- include/pybind11/stl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 32f8d294a..77da13362 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -266,7 +266,8 @@ template struct optional_caster { static handle cast(T_ &&src, return_value_policy policy, handle parent) { if (!src) return none().inc_ref(); - policy = return_value_policy_override::policy(policy); + using dereference_type = decltype(*std::forward(src)); + policy = return_value_policy_override::policy(policy); return value_conv::cast(*std::forward(src), policy, parent); }