
Yes, there is. rtl (Range Templates Library) has a generate_iterator.
You have a generator, and a stopper. From these, you create an input iterator sequence. The stopper tells you when you've reached end.
For instance: // input iterator sequence - 20 fibonacci numbers generated(fibonacci(), gen_n(20))
// input iterator sequence - fibonacci numbers up to 200 generated(fibonacci(), gen_upto(200))
You can use it like this: rng::copy( generated(fibonacci(), gen_upto(200)), std::ostream_iterator<int>(std::cout," "));
The rtl (and the generate* examples) can be found at: www.torjo.com/code/for_boost.zip
The RTL approach looks very interesting. There is a lot to digest here.
What is the state of maturity of this code? Would you consider it ready for use?
I would think so. I've used it successfully in 6 projects so far, 3 of them being > 100000 lines of code each. Best, John -- John Torjo Freelancer -- john@torjo.com -- http://www.torjo.com/logview/ - viewing/filtering logs is just too easy!