-
Hello, However, I cannot get it to work. Even the provided example seems to be broken. I also tried the code from the tests and added four simple functions, which also yield the parent class m.def("test0", []() { return std::unique_ptr<Cat>(new Cat("eine katze")); });
m.def("test1", []() { return std::unique_ptr<Dog>(new Dog("ein hund")); });
m.def("test2", []() { return std::unique_ptr<Animal>(new Cat("poly katze")); });
m.def("test3", []() { return std::unique_ptr<Animal>(new Dog("poly hund")); }); Could it be that this feature, which exists in pybind11, was cut from nanobind? The documentation looks pretty much identical, only with "pybind11" replaced by "nanobind" in the last paragraph. The link in the info box is also broken, which further indicates, that this might have been a copy-past mistake. If I am not doing anything wrong and this feature is currently missing, I would be curious, if there was a plan to add it. Automatic downcasting was not mentioned on the list of removed pybind11 features. It seems pretty useful/important to me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
That's right. This part of the documentation was blatantly copied and still needs some massaging. You are right that this was one of the features that was cut in nanobind (and intentionally so, you should stay with pybind11 if you need it.) |
Beta Was this translation helpful? Give feedback.
That's right. This part of the documentation was blatantly copied and still needs some massaging. You are right that this was one of the features that was cut in nanobind (and intentionally so, you should stay with pybind11 if you need it.)