Boost logo

Boost Users :

From: Nebojsa Simic (nelle_at_[hidden])
Date: 2007-11-17 10:00:44


JOAQUIN LOPEZ MU?Z wrote:
> Hi Nebojsa,
>
> ----- Mensaje original -----
> De: Nebojsa Simic <nelle_at_[hidden]>
> 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_at_[hidden]
>
>> 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

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