infer type argument in classe constructor?

Puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 29 03:13:28 PDT 2016


Hi,

I'm writing a generic class:

```d

struct Message { ... }

class Decoder(MsgSrc) {
}
```

When using it, I'd have to include the type of its argument:

```
void main() {
    Message[] src = ...;

    auto decoder = new Decoder!(Message[])(src);

    ...
}
```

Can it be inferred so that I only need to write?

```d
auto decoder = new Decoder(src); // you can infer the type from 
src.
```


More information about the Digitalmars-d-learn mailing list