Boost Users :
From: Matt S Trentini (matt_s_trentini_at_[hidden])
Date: 2003-11-28 21:33:30
Peter Dimov wrote:
>>But this doesn't compile because the inserters (at least on my
>>platform) don't define value_type.
> They aren't required to. You should use
Ah, makes sense.
>>Am I overlooking something here?
> 1. Iterators are typically passed by value.
I've noticed that - is there are reason for this?
My reason for passing by const reference is mostly academic anyway
because copying iterators is typically cheap, I just have a curious
> 2. You don't need to use boost::function in a template. It is typically only
> used when you want a fixed compile-time signature.
> template<class InIt, class OutIt, class F>
> void Extract(InIt first, InIt last, OutIt out, F f)
> for (; first != last; ++first, ++out)
> *out = f(*first);
> Now look at std::transform. :-)
Oh the shame of it! ;) Covered with embarrassment I've dutifully
erased my Extract function... :)
Kinda funny how sometimes you can't see the wood through the
trees...only yesterday I recommended that a colleague use transform for
(what I now recognise as) a similar application. I got hung up on the
fact that I wanted to use boost::function I guess...
> (You'll no longer be able to pass &X::f directly, though, use mem_fn
For those that are curious here's the improved solution that Peter was
Thanks Peter - both for your help and your work in boost! :)
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