← Back to index
|
Original Bugzilla link
Bug 18525 – Constraint on std.algorithm.mutation.remove fails with char[]
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-02-26T11:00:01Z
Last change time
2018-04-21T16:35:36Z
Assigned to
No Owner
Creator
Adam Wilson
Comments
Comment #0
by flyboynw — 2018-02-26T11:00:01Z
Consider the following code: void main() { import std.algorithm.mutation; import std.stdio: write, writeln, writef, writefln; import std.typecons : tuple; int[] ints; char[] chars; ints = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; writeln(remove(ints, tuple(1, 4))); chars = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ]; writeln(remove(chars, 1)); chars = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ]; writeln(remove(chars, tuple(1, 4))); } While the ints example works, the chars examples fail to compile with the following error output: onlineapp.d(14): Error: template std.algorithm.mutation.remove cannot deduce function from argument types !()(char[], int), candidates are: /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1792): std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable && isBidirectionalRange!Range && hasLvalueElements!Range && hasLength!Range && (Offset.length >= 1)) /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1879): std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s == SwapStrategy.stable && isBidirectionalRange!Range && hasLvalueElements!Range && (Offset.length >= 1)) /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2034): std.algorithm.mutation.remove(alias pred, SwapStrategy s = SwapStrategy.stable, Range)(Range range) if (isBidirectionalRange!Range && hasLvalueElements!Range) onlineapp.d(17): Error: template std.algorithm.mutation.remove cannot deduce function from argument types !()(char[], Tuple!(int, int)), candidates are: /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1792): std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable && isBidirectionalRange!Range && hasLvalueElements!Range && hasLength!Range && (Offset.length >= 1)) /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1879): std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s == SwapStrategy.stable && isBidirectionalRange!Range && hasLvalueElements!Range && (Offset.length >= 1)) /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2034): std.algorithm.mutation.remove(alias pred, SwapStrategy s = SwapStrategy.stable, Range)(Range range) if (isBidirectionalRange!Range && hasLvalueElements!Range) Note: strings are confirmed to work.
Comment #1
by john.loughran.colvin — 2018-03-22T18:07:29Z
Totally separate algorithms required for this case, because of auto-decoding.
https://github.com/dlang/phobos/pull/6328
Comment #2
by github-bugzilla — 2018-04-21T16:35:35Z
Commits pushed to master at
https://github.com/dlang/phobos
https://github.com/dlang/phobos/commit/8d314b5ffbeb67adf27c68e11976a1d63917717b
Fix Issue 18525: std.algorithm.mutate.remove should work on mutable strings
https://github.com/dlang/phobos/commit/7ba6fbb66c960953d61dc334eea1dc9be5220df1
Merge pull request #6328 from John-Colvin/string_remove Fix Issue 18525: std.algorithm.mutate.remove should work on mutable strings merged-on-behalf-of: Nathan Sashihara <
[email protected]
>