$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-05-15 06:53:07
Terence Wilson 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.
template<class It, class F> void for_each_pair(It first, It last, F f)
{
for(; first != last; ++first) f(first->first, first->second);
}
for_each_pair(map.begin(), map.end(), bind(&MyClass::foo, _2));
is what I use.