Boost logo

Boost Users :

Subject: Re: [Boost-users] Iterating over the seconds of a list of pairs
From: dariomt (dariomt_at_[hidden])
Date: 2009-08-27 06:29:51


Björn Karlsson <Bjorn.Karlsson <at> readsoft.com> writes:

>
> ...and now that we've seen the fundamental mechanics involved in using
transform_iterator for this
> problem, here's a really terse version using two other useful libraries;
Boost.Bind and
> Boost.Function.
>
> typedef boost::transform_iterator<
> boost::function<float& (container_type::reference)>,
> container_type::iterator> iterator_type;
>
> The advantages of this approach are that it's short, elegant, and all the
logic is locally defined.

Hello,

I see a possible disadvantage: efficiency. I may be wrong but I see there will
be the extra overhead of a call through boost::function for every iterator
dereference. That is, compared to the version using the functor which would have
no overhead (compared to a hand-made iterator that dereferenced the second
element of a pair).

Please correct me if I'm wrong with this.

Thanks!

PS: when i try to propose using boost I always get: 'Hum... what's the overhead
compared to doing it by hand?'


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