I'm not sure why I can't find any good discussion of this, I have been searching since yesterday.
How do you return a class object from C++ binding and use its methods in Python i.e.:
class A {
...
void foo() {
py::print("Hello world");
}
}
class B {
...
A bar() {
a = A();
// What do I return here if I want to return a and use it in Python
// return a
}
}
I want to then bind B and use it in Python
b_object = B()
a = b_object.bar()
a.foo()
How do I do this in Pybind, Nanobind or Boost Python (if the syntax for the latter is similar).
I can't use lambdas when creating the B
binding. The use case is actually more complex than what I've shown here.