-
Follow-up on #309: How to pass Python strings to nb functions? The following Pybind11 function accepts a Python string: void
foobar(const std::string & input_data) {
// ...
} but gives
in nb. Any hints? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You probably forgot to |
Beta Was this translation helpful? Give feedback.
-
Sorry for hijacking this thread but I have a very related question. void foobar(std::string s);
void foobar(std::vector<std::string> s); and I noticed that nanobind always seems to call the second one, even when passed a single Python string. In that case, it builds a vector containing the individual characters. Is there a way to avoid this? (I'm including both |
Beta Was this translation helpful? Give feedback.
You probably forgot to
#include
the STL type caster for strings. See the "Why another binding library" part of the docs for more detail on why those aren't included anymore.