questions around mutating range algorithms, const, and return ref

Seb seb at wilzba.ch
Mon Jan 29 13:55:04 UTC 2018


On Monday, 29 January 2018 at 11:36:26 UTC, aliak wrote:
> On Monday, 29 January 2018 at 06:46:26 UTC, Ali Çehreli wrote:
>> I think the following trivial wrapper around 
>> std.algorithm.remove() should do:
>>
>> void removeMatching(R, N)(ref R r, N needles) {
>>     import std.algorithm : remove, canFind;
>>     r = r.remove!(e => needles.canFind(e));
>> }
>>
>
> Haha awesome! Yes that's much better :)
>
> Note to self: learn to scroll down in the docs to find other 
> definitions. I was convinced that remove only acted on indices 
> :p

Not too hard to fix: https://github.com/dlang/phobos/pull/6090


More information about the Digitalmars-d-learn mailing list