On 2010-01-29 10:49:34 -0500, "Steven Schveighoffer" <schvei...@yahoo.com> said:

ugh... much simpler with a true stream-like range that supports what is natural for streams:

for(int i = 0; i < count && !range.empty; i++) {
    elements ~= range.get();
}

But of course, then this function doesn't work for other range types. I decided in that discussion long ago that stream ranges were going to suck.

You can always define a generic take() like this:

        E take(R, E)(ref R range) {
                E element = range.front;
                range.popFront();
                return element;
        }

This will work for any forward range.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to