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