Skip to content

Binding of: float* listOfFloats #239

Answered by oremanj
RichardGe asked this question in Q&A
Discussion options

You must be logged in to vote

I would suggest you bind a lambda that accepts std::vector and adapts to the interface of PrintFloats. Something like:

#include <nanobind/stl/vector.h>
...
m.def("PrintFloats", [](const std::vector<float>& v) {
    PrintFloats(v.data(), v.size());
});

Then you would invoke it from Python like PrintFloats([10, 11, 12]).

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by RichardGe
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants