
On Mon, Jan 17, 2011 at 11:57 AM, Ralf Goertz <R_Goertz@usenet.arcornews.de> wrote:
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>
?
I think you might get a better answer from those on the python C++-sig, but I think the problem with that code is that there's no built-in conversion from pair<std::string const,int> to Python. You can add your own converter and then it might work, though. There might also be better ways to do this (e.g. check out the map_indexing_suite). HTH, -- Dave Abrahams BoostPro Computing http://www.boostpro.com