File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,19 @@ NAMESPACE_BEGIN(detail)
1414// / https://github.com/wjakob/nanobind/issues/682#issuecomment-2310746145
1515template<typename T>
1616struct type_caster<std::optional<Eigen::Ref<const T>>>
17- : optional_caster<std::optional<Eigen::Ref<const T>>>
1817{
1918 using Ref = Eigen::Ref<const T>;
2019 using Optional = std::optional<Ref>;
21- using Caster = typename type_caster::optional_caster::Caster ;
20+ using Caster = make_caster<Ref> ;
2221 using Map = typename Caster::Map;
2322 using DMap = typename Caster::DMap;
2423 NB_TYPE_CASTER (Optional, optional_name (Caster::Name))
2524
25+ type_caster ()
26+ : value (std::nullopt )
27+ {
28+ }
29+
2630 bool from_python (handle src, uint8_t flags, cleanup_list* cleanup) noexcept
2731 {
2832 if (src.is_none ())
@@ -39,6 +43,17 @@ struct type_caster<std::optional<Eigen::Ref<const T>>>
3943 value.emplace (caster.caster .operator Map ());
4044 return true ;
4145 }
46+
47+ template <typename T_>
48+ static handle from_cpp (T_&& value,
49+ rv_policy policy,
50+ cleanup_list* cleanup) noexcept
51+ {
52+ if (!value)
53+ return none ().release ();
54+
55+ return Caster::from_cpp (forward_like_<T_>(*value), policy, cleanup);
56+ }
4257};
4358
4459NAMESPACE_END (detail)
You can’t perform that action at this time.
0 commit comments