On 2/18/22 12:16, Salih Dincer wrote:

>    // x.writeln(y); // 2.087
>    "D Compiler v".writeln(__VERSION__/1000.0);
> ```
> I'm using v2.087 but because of @disable this line doesn't work: ```//
> x.writeln(y); // 2.087```
>
> Why? Can you give an explanation for this?

This is not related to struct initialization. The issue can be reduced to the following:

struct S {
  @disable this(this);
}

void foo(S s) {
}

void main() {
  auto s = S();
  foo(s);
}

Error: struct `deneme.S` is not copyable because it has a disabled postblit

foo takes by-value but S disables copying. The same thing happens with your example inside a Phobos function:

    void write(S...)(S args)
    {
    // ...
        foreach (arg; args)
        // ...
    }

foreach iterates the arguments by-value there. Same issue.

Ali

Reply via email to