moveAt vs opIndex

maarten van damme maartenvd1994 at gmail.com
Fri May 18 05:21:23 PDT 2012


I am trying to write a randomaccessinfinite range that returns primes
using the sieve of aristotle. I am however having problems
understanding the difference between moveAt and opIndex;

according to dlang;
ElementType opIndex(size_t n);
Returns the nth element in the composite range. Defined if all ranges
offer random access.

ElementType moveAt(size_t n);
Destructively reads the nth element in the composite range. Defined if
all ranges offer random access.

Whats the difference between destructively reading and returning?

And why would I need to define moveFront and front when I already
defined opIndex?


More information about the Digitalmars-d-learn mailing list