variable _param_0 cannot be read at compile time

learnfirst1 learnfirst1 at gmail.com
Fri Aug 10 02:53:05 UTC 2018


On Thursday, 9 August 2018 at 13:42:03 UTC, Kagamin wrote:
> struct M {
>         int i;
>         S*[100] s;
> }
> struct S {
>         M* mp;
>         bool x;
> }
>
> S* add(A...)() {
>         alias m = A[0];
>         __gshared s = S(&m,A[1..$]);
>         m.s[m.i++] = &s;
>         return &s;
> }
>
> void main(){
>         __gshared M m = M(0);
>         __gshared S s = S(&m, false);
>         m.s[m.i++] = &s;
>         auto p = add!(m, true);
> }

this is what I want! thanks.



More information about the Digitalmars-d-learn mailing list