From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-05-23 08:31:12


Darin Buck wrote:
[...]
> void callfunctor(pair < string, MessageFunctor > item, unsigned long
> long pk)
> {
> item.second(pk);
> }
[...]
> void sendMessage(message& amessage)
> {
> MessageFunctorTableMapIteratorPair iterPair =
> mHandlerMap.equal_range(amessage.mtablename);
> std::for_each(iterPair.first, iterPair.second, boost::bind
> (&callfunctor, _1, amessage.mpk)); // QUESTION LINE
> }
[...]
> now for the question:
>
> on the line labeled "QUESTION LINE", you can see that I'm
> binding to
> a functor called "callfunctor". All callfunctor does is call
> the
> functor embedded in the map's pair.
>
> Is there a way to simplify the line in question so that I don't
> need
> to create the functor just to get access to the pair.second member?

I don't see an easier way to accomplish the same effect. You can access
pair.second without an additional function object but you'll still have to
add one in order to invoke it.