Terence Wilson <[EMAIL PROTECTED]> wrote: > I could use some help with bind syntax. I have a container: > > Class MyClass > { > public: > void foo(void); > } > > Std::map<int, boost::shared_ptr<MyClass> > > > I would like to construct a for_each loop with calls to foo for every > pointer to MyClass in the map. Help greatly appreciated.
typedef std::map<int, boost::shared_ptr<MyClass> > my_map; typedef my_map::value_type my_map_pair; my_map m; std::for_each(m.begin(), m.end(), boost::bind(&MyClass::foo, boost::bind(&my_map_pair::second, _1))); The inner bind extracts the field "second" from the iterator. The outer bind calls the method. You can call a method from either an instance of the class, a dumb pointer to an instance or a smart pointer to an instance, it will just work. Giovanni Bajo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost