Inferring static array size
NotYouAgain
NotYouAgain at gmail.com
Sun Apr 28 09:43:30 UTC 2024
On Sunday, 28 April 2024 at 09:35:22 UTC, Chloé wrote:
>
> The Phobos function staticArray can be used to infer the array
> length while explicitly specifying (or inferring) the element
> type:
>
> import std.array : staticArray;
> auto a = [1, 2, 3, 4, 5].staticArray; // inferred int[5]
> auto b = [1, 2, 3, 4, 5].staticArray!float; // inferred
> float[5]
Oh. interesting, I didn't know. Thanks.
but...
auto a = 20.iota.array.staticArray;
// Error: none of the overloads of template
`std.array.staticArray` are callable using argument types
`!()(int[])`
More information about the dip.ideas
mailing list