std.algorithm.remove: Fix constraints and change popBack loop to popBackN#2256
std.algorithm.remove: Fix constraints and change popBack loop to popBackN#2256DmitryOlshansky merged 2 commits intodlang:masterfrom
Conversation
|
So it doesn't solve issue 8930 but patches the constraints. Anyhow a net progress, so LGTM. |
std/algorithm.d
Outdated
There was a problem hiding this comment.
s/popBackN/popBackExactly/
popBackN will actually pop "up to" N elements, checking for empty in between each call.
There was a problem hiding this comment.
Change all of the pop____Ns to pop____Exactlys? Note that the parameter is derived from input, so erroneous input will cause undefined behaviour.
EDIT: I suppose we can use the other popBack's to validate calling popBackExactly
There was a problem hiding this comment.
Yes, change pop____N to pop____Exactly.
Yes, it will cause undefined behavior, but the input is erroneous anyways.
|
Well, arguably, you don't need lvalue elements to be able to swap. For example I perfectly fine with constraining the function to only accept what it actually works on, and we can relax them later once we have a better working implementation. |
This was my line of thinking, btw I'm not interested fixing 8930. |
|
@monarchdodra ping, could you please answer my questions? |
|
@DmitryOlshansky Could we please just move forward with this? If somebody wants to optimize with |
Sorry I didn't see this any earlier. Just do it now, and we're good to go. |
|
Ok rebased on top of master and added a commit for the change from Note that I changed the |
|
Auto-merge toggled on |
|
Thanks! |
|
Hey, sorry I wasn't that proactive reviewing this pull. Things have been difficult for me recently IRL. Thanks for sticking with this. |
std.algorithm.remove: Fix constraints and change popBack loop to popBackN
Don't worry about it. :) |
std.algorithm.remove: Fix constraints and change popBack loop to popBackN
See also: https://issues.dlang.org/show_bug.cgi?id=8930
Remove with swap strategy stable requires bidirectional range for popback.