News for hackers. Stuff that matters.
Re:An Idiot's Guide to C++ Templates - Part 1 by btilly on Tuesday April 23, 2013 @12:35PM (#5596173)
The interface that I describe can be backed by a collection, data streamed externally (eg from a file), or by something generated on the fly. Therefore you can write code for all three cases that looks very similar.

That article demonstrated the power of this idea by writing code that fairly efficiently generates the Hamming sequence, which consists of all positive integers whose only divisors are 2, 3, and 5. (So 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, ...)

Re:An Idiot's Guide to C++ Templates - Part 1 by X-Istence on Tuesday April 23, 2013 @12:52PM (#5596277)
You can create your own type of iterator that when dereferenced spits out the next number/item, So long as your "end" iterator never matches your "current" iterator it will continue going on. Your "done" function is when "current" and "end" match. "next()" is "++current".