[C++-sig] map of vectors with indexing suites
Nicolas Rougier
Nicolas.Rougier at loria.fr
Thu May 22 20:51:05 CEST 2008
Thanks, that helps a lot...
Any idea on how to iterate ?
Nicolas
On Thu, 2008-05-22 at 10:40 -0700, Ralf W. Grosse-Kunstleve wrote:
> > Also, I would like to have a nice __repr__ method for the map and the
> > vectors but I did not find how to add easily such methods (currently, I
> > create a class that inherit the std::map only to add the repr method).
>
> You can simply .def() an unbound function implementing __repr__. The only
> requirement is that the first argument of the unbound function is "self".
> E.g.
>
> void foo(your_type const& self);
>
> class_<your_type>("your_type")
> .def("foo", foo)
> ;
>
> Ralf
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
More information about the Cplusplus-sig
mailing list