Transience of .front in input vs. forward ranges

Jonathan M Davis jmdavisProg at gmx.com
Mon Nov 12 12:51:34 PST 2012


On Monday, November 12, 2012 20:51:53 Tommi wrote:
> Then you'd solve this issue by specifying range concept so that
> front should return by value if it's transient, and front should
> return by reference or const reference if it's persistent.

That wouldn't work. It's the complete opposite of what a generative range 
would require if it generates the return value in front. Narrow strings in 
particularly would be screwed by it, because their front is calculated, and 
since it's a free function, as is popFront, there's no way to save the return 
value of front in popFront. It has to be calculated in front, and it's not at 
all transient.

It also screws with the ability to have sealed containers, since in that case, 
something like front would never return by ref.

The refness of front's type really shouldn't have anything to do with its 
transience. They're completely unrelated.

- Jonathan M Davis


More information about the Digitalmars-d mailing list