-
When trying to pass a
Converting it to a
String literals work. Any hints? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
What I would suggest is that you make your own |
Beta Was this translation helpful? Give feedback.
nb::str
has an explicit conversion fromchar *
(but not an implicit one!). You must cast it like so:nb::str(std_str.c_str())
. There is no way that there could be anb::str
constructor that takesstd::string
— nanobind tries as hard as possible to not include any unnecessary STL headers.What I would suggest is that you make your own
nb::str
subclass (nschloe_str
;)) with all the implicit and explicit constructors you fancy. Since it derives from a builtin wrapper type, nanobind knows how to accept and return it in bindings.