Why does `static foreach` lead to something calling `~=` internally?
0xEAB
desisma at heidel.beer
Sun Jul 7 16:51:57 UTC 2019
Why does this `static foreach` lead to hidden usage of operator
`~=` calls in some cases?
> static foreach(i; 0 .. cnt)
> onlineapp.d(9): Error: cannot use operator ~= in @nogc delegate
> onlineapp.xv!(myUDA("/")).__funcliteral2.__lambda1
> import std.traits;
>
> private @safe pure nothrow @nogc
> {
> enum xv(alias uda) = function()
> {
> enum cnt = 10;
>
> static foreach(i; 0 .. cnt)
> {
> }
> };
> }
>
> struct myUDA
> {
> string path;
> }
>
> @myUDA("/")
> void doSth(string path)
> {
> }
>
> extern(C) void main()
> {
> xv!(getUDAs!(doSth, myUDA))();
> }
Try: https://run.dlang.io/is/clQgeA
More information about the Digitalmars-d-learn
mailing list