range.save

Joseph Rushton Wakeling via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 27 00:53:24 PST 2015


On Thursday, 26 November 2015 at 17:23:07 UTC, Andrei 
Alexandrescu wrote:
> So initially I thought a simple solution would be this:
>
> struct MyForwardRange
> {
>     enum bool isForward = true;
>     ... empty, front, popFront ...
> }
>
> enum isForwardRange(R) =
>   is(typeof(R.isForward)) && R.isForward;
>
> Then there's no need for .save(), and isForward!R can be used 
> for constraints etc. Reference forward ranges are not supported 
> but then that's liberating (fewer complications), rare, and 
> easy to work around by wrapping.

By "reference forward range" do you mean a reference type (per 
se) or any range that contains an internal reference type (e.g. a 
range whose private data includes a dynamic array)?


More information about the Digitalmars-d mailing list