"jefflholle"
I've just started experimenting with version 2 of boost.python.
In iterator.cpp, a std::list is wrapped using following code:
typedef std::list<int> list_int; void push_back(list_int& x, int y) { x.push_back(y); }
int back(list_int& x) { return x.back(); } . . . class_
("list_int") .def("push_back", push_back) .def("back", back) .def("__iter__", iterator ()) ; Is it possible to use the container methods instead of user defined functions?
Sure. But not for the standard containers, because you can't portably take the address of a standard library (member) function. The implementation is allowed to add overloads and default arguments, so there's no way to reliably identify the function you're looking for.
I've tried the code: class_
("list_int") .def("push_back", &list_int::push_back) .def("back", &list_int::back) .def("__iter__", iterator ()) ; This doesn't work. Am what I'm tried to do possible?
Yes.
If so, how?
Write your own container, with predictable function signatures ;-) -- David Abrahams dave@boost-consulting.com * http://www.boost-consulting.com