Bug 8930 – std.algorithm.remove only operates on hasLvalueElements
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-01T09:57:19Z
Last change time
2019-12-14T08:14:56Z
Keywords
contracts
Assigned to
monarchdodra
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2012-11-01T09:57:19Z
//----
import std.algorithm;
import std.container;
void main()
{
auto r = Array!int([1, 2, 3])[];
r.remove!"a == 2"();
}
//----
src\phobos\std\algorithm.d(6740): Error: template std.algorithm.move does not match any function template declaration
src\phobos\std\algorithm.d(1336): Error: template std.algorithm.move cannot deduce template function from argument types !()(int,int)
//----
The call to "move" is smart, but pre-supposes the range has Lvalue elements. remove should be able to work just fine for encapsulating ranges such as container's.
Just a bit of change in the doc, and sparkle a few static ifs in the implementation.
Comment #1 by jrdemail2000-dlang — 2016-04-30T19:22:44Z
A related thread from the learn forum: https://forum.dlang.org/thread/[email protected]
Example from the thread:
char[] thing = ['a', 'b', 'c'];
thing = thing.remove(1);
The above does not compile. Switching to However, the following does:
ubyte[] thing = ['a', 'b', 'c'];
thing = thing.remove(1);
Many users might expect remove to work on char[] also. It does work with dchar[] arrays.