JOAQUIN LOPEZ MU?Z wrote:
Hi Nebojsa,
----- Mensaje original ----- De: Nebojsa Simic <nelle@sbox.tugraz.at> Fecha: Sábado, Noviembre 17, 2007 0:05 am Asunto: Re: [Boost-users] [multiindex] [bind] Update members of the container between two iterators (was: Conversion loses qualifiers) Para: boost-users@lists.boost.org
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:
So, the current status is: // TEMPLATE FUNCTION for_each_it template<class _InIt, class _Fn1> inline _Fn1 for_each_it(_InIt _First, _InIt _Last, _Fn1 _Func) { // perform function for each element for (; _First != _Last; ++_First) _Func(_First); return (_Func); }; and when I try to do this : for_each_it( it , idxResponse.end() , boost::bind( &StatisticsByResponse::modify, idxResponse, ::_1, fnAddStats ) ); still get compilation errors. What am I missing here ? as a temporary solution I added : inline bool bloodyBindable( StatisticsByResponse& index, const StatisticsByResponse::iterator& it, boost::function<void(Statistics&)> fnc ) { return index.modify( it, fnc ); } for_each_it( it , idxResponse.end() , boost::bind( bloodyBindable, idxResponse, ::_1, fnAddW0 ) ); which compiles, but I just want to know what am I doing wrong. -- Nebojsa Simic