You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# in python, assign values from listobject.set_value([1.0, 2.0, 3.0, ...])
Nanobind can convert the list implicitly to VectorF and then get std::vector<double> from it (due to implicitly_convertible<iterable, Vector>() in bind_vector), so above codes run without problems. However, to make codes more efficient, I'd like to move the vector if it is implicitly created, something like below:
def set_value(T& self, pointer_and_handle<std::vector<double>> object) {
if (is_implicitly_created(object.h)) {
self.vec = std::move(*object.p);
} else {
self.vec = *object.p; // in case this vector if from `VectorF ` in python which owns the data.
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, currently I have a use case that an be simplified like below:
Nanobind can convert the
listimplicitly toVectorFand then getstd::vector<double>from it (due toimplicitly_convertible<iterable, Vector>()inbind_vector), so above codes run without problems. However, to make codes more efficient, I'd like to move the vector if it is implicitly created, something like below:Is there any way I can achieve this?
Beta Was this translation helpful? Give feedback.
All reactions