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
> 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_itera... 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