Forward ranges in Phobos v2

Dukc ajieskola at gmail.com
Mon Nov 1 14:39:40 UTC 2021


On Monday, 1 November 2021 at 14:13:00 UTC, H. S. Teoh wrote:
> Based on what Andrei said in the past, there will no longer be 
> .save (which has always been a point of confusion in the API 
> and interacts poorly with the type system), but forward ranges 
> will be based on by-value semantics, and input ranges on 
> by-reference semantics. So if it's a by-value type, it's a 
> forward range; if it's a by-reference type, it's an input range.
>
> If you have a struct but it only supports input range 
> semantics, then you could pass it by ref or pass a pointer to 
> it.
>
> If you have a class but it supports forward range semantics, 
> then wrap it in a struct with a copy ctor that saves state in 
> the copy ctor.
>
>
> T

Simple and effective! I think that's what I'm voting for.


More information about the Digitalmars-d mailing list