On Tuesday, 7 February 2023 at 09:49:46 UTC, Salih Dincer wrote:
Is it a feature or a bug that the code below can be compiled without arguments?

You should use `@disable this()` recommended in the relevant article: https://dlang.org/spec/struct.html#disable_default_construction

```d
void main()
{
    auto noArgument = Sarr!char(); // no compile
}
```

On Tuesday, 7 February 2023 at 09:49:46 UTC, Salih Dincer wrote:
I want to learn one more thing. Why can't the default argument be used in alias of structs?

```d
void main()
{
    auto bar = Sarr!()(dlang.dup); // complied
    assert(is(typeof(bar.arr[0]) == char));
}
```
😀

SDB@79


  • Default arguments Salih Dincer via Digitalmars-d-learn
    • Re: Default arguments Salih Dincer via Digitalmars-d-learn

Reply via email to