Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
Nick Treleaven
nick at geany.org
Wed Jan 6 18:29:05 UTC 2021
On Wednesday, 6 January 2021 at 18:14:42 UTC, Luhrel wrote:
> It works only for the `int` type and above (and other types as
> structs).
>
> example with short:
> ---
> extern(C) void main()
> {
> import std.array;
> auto a = [0, 1].staticArray!short; // error
> }
Can be fixed (probably with another name):
//import std.array;
import std.stdio;
void main(){
auto a = [1,2,3].staticArray!float;
pragma(msg, typeof(a)); // float[3]
a.writeln();
}
template staticArray(T) {
T[n] staticArray(ulong n) (auto ref T[n] a) {return a;}
}
More information about the Digitalmars-d-announce
mailing list