static array with inferred size
Steven Schveighoffer
schveiguy at yahoo.com
Wed Sep 20 14:15:30 UTC 2017
On 9/20/17 3:12 AM, Dgame wrote:
>
> http://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits
This is plain stack corruption, you should fix that. The s template
seems useful, but still I can't get my use case to work with it:
T[n] s(T, size_t n)(auto ref T[n] array) pure nothrow @nogc @safe
{
return array;
}
void main()
{
char[5] x1 = "hello"; // works.
auto x2 = s("hello"); // oops, type is immutable(char[5]);
auto x3 = s!char("hello"); // template s cannot deduce function
from argument types !(char)(string)
}
-Steve
More information about the Digitalmars-d
mailing list