Hi Nebojsa,
----- Mensaje original -----
De: Nebojsa Simic
Nebojsa Simic wrote: [...]
for_each( it , idxResponse.end() , boost::bind( &StatisticsByResponse::modify, boost::ref(idxResponse), ::_1, fnAddStats ) );
but it still does not compile (problem with boost::bind "wrong number of arguments").
the call : idxResponse.modify( it, fnAddStats ); works, so the problem is not the first bind, but the one in for_each.
[...]
You can't use for_each(it1,it2,someFunctor) to do what you want because modify() needs an iterator, and for_each passes a value reference to someFunctor rather than the iterator. So, you've got to resort to a handmade loop like: for(StatisticsByResponse::iterator it=m_statistic.project<1> (result.first), it_end=idxResponse.end(); it!=it_end;++it){ idxResponse.modify(it,boost::bind (&Statistics::addStats,::_1,val,tick)); } A warning about modifying elements of a multi_index_container in a loop: if your modification affects the key on which the index you're traversing depends upon, then the loop is broken, because when you call modify(...) the element will be rearranged in the index and along with it the iterator "it". If this is your case, please read the following post where mechanisms for range modifying are provided: http://lists.boost.org/boost-users/2006/03/18048.php (Note that post comes with some usable code attached). Hope this helps, thanks for using Boost.MultiIndex, if something's still not clear do not hesitate to come back. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo