Boost logo

Boost Users :

Subject: [Boost-users] [boost::python] iterator from member container
From: Ralf Goertz (R_Goertz_at_[hidden])
Date: 2011-01-17 11:57:44


Is ist possible to have a class that has a map as member like

struct Foo {
        std::map<string,int> bar;
};

and then something like

class_<Foo>("Foo")
        .def("__iter__", iterator<std::map<string,int>());

so that in python an object foo of type Foo can be used like this

for i in foo:
        <do something with the bar iterator i>

?

Ralf


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