RefRange

Jonathan M Davis jmdavisProg at gmx.com
Sun Aug 26 10:17:13 PDT 2012


On Sunday, August 26, 2012 17:41:45 David wrote:
> It's a RefRange, but not completly ... Can somebody explain me that
> behaviour?
>
> http://dpaste.dzfl.pl/643de2a3

refRange simply returns the original range if it's an input range rather than 
a forward range, since normally, when you have an input range, it isn't a 
value type, and there's no way to copy it, so operating on one reference of it 
is already the same as operating on all of them, making RefRange pointless.

However, you've done the odd thing of declaring a value type input range. I 
don't know why that would ever be done except through ignorance of how ranges 
work. So, refRange is actually returning a copy in your case, which is why 
you're having problems.

And by the way, the only reason that rr.x works is because refRange is 
returning a copy rather than a RefRange!TestRange.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list