I have structs like this:
struct A{
void do_stuff(){...does stuff};
}
struct B{
std::vector<std::shared_ptr<A>> objs;
}
my pybind:
py::class_<A>(m, "A")
.def("do_stuff", &A::do_stuff)
py::class_<B>(m, "B")
.def_readwrite("objs", &B::objs);
Behaviour I'm trying to reach:
import mybind
b_instance = mybind.B()
for a_instance in b_instance:
a_instance.do_stuff()
Unfortunately, I get
MemoryError: std::bad_alloc
Please, help me out. Code above is not actually the code I work with. Class A works by itself, but doesn't when iterating through B. If this code is not enough please write in the comments. Thanks!