Bug 4346 – More flexible std.array.array

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-06-19T06:32:00Z
Last change time
2010-08-18T17:55:40Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-06-19T06:32:28Z
Dmd v2.047 rejects all the following programs: import std.array: array; void main() { int[2] a = [1, 2]; assert(array(a) == [1, 2]); } import std.container: SList; import std.array: array; void main() { auto l = SList!int(1, 2); assert(array(l) == [1, 2]); } import std.container: SList; import std.array: array; void main() { auto l = SList!int(1, 2); assert(array(l[]) == [1, 2]); } If a collection can be iterated with foreach, and its items can be copied, then array() has to work on it (and use the Appender for performance where the length of the collection is not known). See also bug 4114
Comment #1 by dsimcha — 2010-08-18T17:55:40Z