Boost logo

Boost Users :

From: jefflholle (jeff.holle_at_[hidden])
Date: 2002-10-28 21:02:11


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>("list_int")
        .def("push_back", push_back)
        .def("back", back)
        .def("__iter__", iterator<list_int>())
        ;

Is it possible to use the container methods instead of user defined
functions? I've tried the code:
   class_<list_int>("list_int")
        .def("push_back", &list_int::push_back)
        .def("back", &list_int::back)
        .def("__iter__", iterator<list_int>())
        ;
This doesn't work.

Am what I'm tried to do possible?

If so, how?
   


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net