I am often facing the same thing again and again. Say I have a map: map< int, Foo* > m; and I would like to invoke method of Foo on all instances std::for_each(m.begin(), m.end(), boost::bind(&Foo::method, _1 ); The problem is that map contains pair of key and value, not Foo*. Usually I create some function taking pair and invoking method needed on .second. But maybe there is another way to do that? Thanks! Vytautas
Hello Vytautas, Friday, July 30, 2004, 8:04:16 PM, you wrote: VL> I am often facing the same thing again and again. Say I have a map: VL> map< int, Foo* > m; VL> and I would like to invoke method of Foo on all instances VL> std::for_each(m.begin(), m.end(), boost::bind(&Foo::method, _1 ); VL> The problem is that map contains pair of key and value, not Foo*. Usually I VL> create some function taking pair and invoking method needed on .second. But VL> maybe there is another way to do that? At present time i'm using expressions like this: typedef map< int, Foo* > M; M m; std::for_each( m.begin(), m.end(), boost::bind( Foo::method, boost::bind(&M::value_type::second, _1) ) ); but maybe there is a way to write it more compact. -- Best regards, Владимир mailto:vkrasovsky@yandex.ru
participants (2)
-
Vytautas Leonavicius
-
Владимир Красовский