https://issues.dlang.org/show_bug.cgi?id=8008
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #9 from [email protected] --- > the []s syntax is handy to solve the problem, avoiding to create and manage > a new type and keeping all safety: > > void main() @nogc { > import std.range: iota; > import std.algorithm: map; > auto pairs = 10.iota.map!(i => [i, i + 10]s); > foreach (p; pairs) {} // OK > } What do you think about: ---- import std.stdio; auto ref U[N] s(U, alias N)(auto ref U[N] arr) pure nothrow @safe @property @nogc if (__traits(compiles, { size_t i = N; })) { return arr; } void test1(T)(T[3] arr) { } void test2(T)(auto ref T[3] arr) { } void main() { auto a = s([1, 2, 3]); writeln(typeid(a)); auto b = [1, 2, 3].s; writeln(typeid(b)); test1([1, 2, 3]); test1([1, 2, 3].s); test2([1, 2, 3].s); } ---- --
