So I have a vector of foo that I exposed with the indexing suite, and I need to deepcopy it. I get a Boost.Python.ArgumentError exception when I try to iterate across the result later.<br><br>>>> from BusyBox import *<br>
>>> foo<br><class 'BusyBox.foo'><br>>>> vecfoo<br><class 'BusyBox.vecfoo'><br>>>> vf = vecfoo()<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>
>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>
>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> vf.append(foo())<br>>>> for f in vf:<br>
... f.__repr__()<br>...<br>'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>
'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>'<BusyBox.foo object at 0x00A81EF0>'<br>
'<BusyBox.foo object at 0x00A81F70>'<br>'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>
'<BusyBox.foo object at 0x00A81EF0>'<br>'<BusyBox.foo object at 0x00A81F70>'<br>>>> import copy<br>>>> vf2 = copy.deepcopy(vf)<br>>>> for f in vf2:<br>... f.__repr__()<br>
...<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>Boost.Python.ArgumentError: Python argument types in<br> vecfoo.__iter__(vecfoo)<br>did not match C++ signature:<br>
__iter__(struct boost::python::back_reference<class std::vector<struct foo,class std::allocator<struct foo> > &>)<br>>>><br><br>here is my c++ code:<br>struct foo<br>{<br> foo(){} ;<br>
foo(int init_x, int init_y){x=init_x;y=init_y;};<br> int x;<br> int y;<br><br> bool operator==(const foo &rhs) const;<br>};<br><br>bool foo::operator==(const foo &rhs) const {return (this == &rhs);}<br>
struct foo_wrapper : foo , wrapper<foo><br>{<br> foo_wrapper();<br> foo_wrapper(const foo& f);<br> foo_wrapper(int init_x, int init_y);<br> static bool eq(const foo& lhs, const foo &rhs);<br>
};<br>foo_wraper::foo_wrapper(const foo& exch): foo(exch), wrapper<foo>(){}<br>foo_wrapper::foo_wrapper(): foo(), wrapper<foo>(){}<br>foo_wrapper::foo_wrapper(int init_x, int init_y) : foo(init_x,init_y), wrapper<foo>(){}<br>
bool foo_wrapper::eq(const foo& lhs, const foo &rhs) {return (lhs == rhs);}<br><br>Later:<br><br> class_<foo_wrapper>("foo")<br> .def(init<>())<br> .def(init<int, int>())<br>
.def_readwrite("x", &foo::x )<br> .def_readonly ("y", &foo::y )<br> .def("__eq__", &foo_wrapper::eq)<br> ;<br><br> class_<std::vector<foo> > ("vecfoo")<br>
.def(vector_indexing_suite< std::vector<foo>, true >() );<br><br><br><br>