Is there something like a consuming take?
berni
someone at somewhere.com
Sat Jul 6 12:10:13 UTC 2019
On Saturday, 6 July 2019 at 11:48:51 UTC, a11e99z wrote:
> sure
> auto take_consuming( R )( ref R r, int cnt ) {
> auto tmp = r.take( cnt ).array;
> r = r.drop( cnt );
> return tmp;
> }
> don't thank
Doesn't look like what I'm looking for, as it is exactly the same
I allready found.
Maybe I need to explain, what I dislike with this approach:
take() calls popFront n times and drop() calls popFront another n
times giving a total of 2n times (depending on the underlying
range, this might cause lot's of calulcations be done twice. The
first version with the foreach loop calls popFront only n times.
More information about the Digitalmars-d-learn
mailing list