Reputation: 429
I have a trampoline class that I am trying to wrap in nanobind like so:
class PyT : T {
public:
NB_TRAMPOLINE(T, 1);
void F() override {
NB_OVERRIDE(F);
}
};
// ...
nb::class_<T, PyT>(m, "T")
.def(nb::init<>())
.def("f", &PyT::F)
It compiles fine, but when i go to use it in python, it only works if I call the function as F()
despite wrapping it with the method name f()
.
How do I solve this?
Upvotes: 2
Views: 121
Reputation: 429
You can solve this by using NB_OVERRIDE_NAME
and specifying the name you want it to be overriding, so in this case it would be:
void F() override {
NB_OVERRIDE_NAME("f", F);
}
Upvotes: 2