Forward ranges in Phobos v2
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Tue Nov 2 00:05:48 UTC 2021
On Monday, 1 November 2021 at 23:46:07 UTC, H. S. Teoh wrote:
> Good question, ask Andrei. ;-)
Well, I hope he will check this thread and comment on it.
> Presumably, if we standardize on structs/classes, it could be
> as simple as:
>
> auto myFunc(R)(R range) if (is(R == struct)) {
> ... // forward range
> }
>
> auto myFunc(R)(R range) if (is(R == class)) {
> ... // input range
> }
>
> But given that Andrei thinks it's a mistake for ranges to be
> implemented as classes, I've no idea.
That would work, if you have templated funcs, but what if you
need it in an interface?
If class based ranges are to be in D language, I doubt it will be
possible to avoid .save function completely. At least for range
interfaces, the save of forward range will have to be expressed
through a method, such as .save.
More information about the Digitalmars-d
mailing list