Replies: 1 comment
-
You're in luck: @oremanj added a new feature in the latest version of nanobind that I think could be used to support your use case: https://nanobind.readthedocs.io/en/latest/api_core.html#_CPPv4I0EN8nanobind11call_policyE |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say that I have
Item
s that referenceParent
.Parent
can return a vector with a number of such itemsAll items should nurse their parent. If a single
Item
was returned, I'd just addkeep_alive
:but if I try to do the same with a vector of items (the function
get_items()
defined above):it complains that
nanobind::detail::keep_alive(): could not create a weak reference! Likely, the 'nurse' argument you specified is not a weak-referenceable type!
. (OK, the list can't be a nurse.)How to solve it?
If I could use
rv_policy::reference_internal
, the policy would be passed to all elements and I think everything would just work. But in my case the items are not internal members. Is there a way to somehow passkeep_alive
to all elements of a list?Beta Was this translation helpful? Give feedback.
All reactions