Boost logo

Boost Users :

Subject: Re: [Boost-users] Overloading boost::for_each()
From: David Abrahams (dave_at_[hidden])
Date: 2010-08-30 08:05:14


At Mon, 30 Aug 2010 00:43:57 +0100,
Mathias Gaunard wrote:
>
> Of course, for certain data structures, providing a step-generator, as I
> call it, can still be too complicated, and they could only have a
> 'global' generator, which, in the case or our deque, would be:
>
> template<typename T>
> struct deque_generator
> {
> typedef T output_type;
>
> deque_generator(deque& deq_) : deq(deq_) {}
>
> template<typename Out>
> Out operator()(Out out)
> {
> for(typename deque::const_iterator it = deq.begin(); it !=
> deq.end(); ++it)
> out = copy(*it++, out);
> return out;
> }
>
> private:
> typedef vector< array<T, whatever> > deque;
> deque &deq;
> };
>
> In the case of a global generator, implementing algorithms such as
> std::accumulate should be basically the same thing as the
> string_appender example here:
> <http://www.boost.org/doc/libs/1_44_0/libs/iterator/doc/function_output_iterator.html>
> In the case of the step one, it's the same except you need to do it in a
> loop.

[Followup-To set to the developers' list, as this doesn't seem like a
boost-users discussioin anymore.]

Hi Mathias,

Thanks, but you only answered the first part of my question. I don't
understand how you'd use such a thing.

Thanks again.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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