myrange.at(i) for myrange.dropExactly(i).front

Ary Borenszweig via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 25 17:28:31 PDT 2014


On 7/25/14, 6:39 PM, Jonathan M Davis wrote:
> On Friday, 25 July 2014 at 21:33:23 UTC, Timothee Cour via
> Digitalmars-d-learn wrote:
>> Is there a function for doing this?
>> myrange.at(i)
>> (with meaning of myrange.dropExactly(i).front)
>> it's a common enough operation (analog to myrange[i]; the naming is from
>> C++'s std::vector<T>::at)
>
> That would require a random access range, in which case you can just
> index directly. For a non-random access range, which you're doing would
> be the most direct way of doing it.
>
> - Jonathan M Davis

No, the OP said the meaning was `myrange.dropExactly(i).front`, which is 
not a random access.

Sometimes you *do* want the n-th element of a range even if the range is 
not a random access.


More information about the Digitalmars-d-learn mailing list