|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-09-15 16:15:56
Alexander Shyrokov wrote:
> How can make the following code inside of for_each more readable?
>
> void f(char*);
> typedef std::map<int,char> TMap;
> TMap a;
>
> std::for_each(a.begin(),a.end(),boost::bind(f,boost::bind(&TMap::value_type::second,_1)));
I use indentation:
std::for_each( a.begin(), a.end(),
boost::bind( f,
boost::bind( &TMap::value_type::second, _1 )
)
);
or a custom for_each for maps:
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( a.begin(), a.end(), boost::bind( f, _2 ) );
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net