Bug 19835 – Make std.algorithm.mutation.copy accept static arrays as sources

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-04-28T06:08:11Z
Last change time
2019-07-06T00:25:42Z
Keywords
pull
Assigned to
No Owner
Creator
feklushkin.denis

Comments

Comment #0 by feklushkin.denis — 2019-04-28T06:08:11Z
import std.algorithm.mutation; void main() { ubyte[2] a = [ 1, 5 ]; ubyte[] buf; buf.length = 40; auto rem = a.copy(buf); // worked on 2.085.1, broken in 2.086 } Error message: onlineapp.d(10): Error: template std.algorithm.mutation.copy cannot deduce function from argument types !()(ubyte[2], ubyte[]), candidates are: /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(368): std.algorithm.mutation.copy(SourceRange, TargetRange)(SourceRange source, TargetRange target) if (isInputRange!SourceRange && isOutputRange!(TargetRange, ElementType!SourceRange))
Comment #1 by dlang-bot — 2019-06-13T03:51:31Z
@shove70 created dlang/phobos pull request #7070 "Fix issue 19835 - std.algorithm.mutation.copy static array source arg…" fixing this issue: - Fix issue 19835 - std.algorithm.mutation.copy static array source argument broken https://github.com/dlang/phobos/pull/7070
Comment #2 by n8sh.secondary — 2019-06-23T14:02:20Z
The `std.algorithm.*` packages are for working on input ranges, which static arrays are not. I think accepting them isn't a bad idea but I'm going to relabel this from "bug" to "enhancement" and change the title to reflect this.
Comment #3 by shove — 2019-06-24T09:49:10Z
(In reply to feklushkin.denis from comment #0) > import std.algorithm.mutation; > > void main() > { > ubyte[2] a = [ 1, 5 ]; > ubyte[] buf; > buf.length = 40; > > auto rem = a.copy(buf); // worked on 2.085.1, broken in 2.086 > } > > Error message: > > onlineapp.d(10): Error: template std.algorithm.mutation.copy cannot deduce > function from argument types !()(ubyte[2], ubyte[]), candidates are: > /dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(368): > std.algorithm.mutation.copy(SourceRange, TargetRange)(SourceRange source, > TargetRange target) if (isInputRange!SourceRange && > isOutputRange!(TargetRange, ElementType!SourceRange)) Before this question is pending, you can: import std.algorithm.mutation; void main() { ubyte[2] a = [ 1, 5 ]; ubyte[] buf; buf.length = 40; auto rem = a[0 .. $].copy(buf); // worked on 2.085.1, broken in 2.086 }
Comment #4 by feklushkin.denis — 2019-06-24T11:52:53Z
Thanks!