Deduce type of struct in function arguments

Andrey saasecondbox at yandex.ru
Mon Aug 20 12:33:34 UTC 2018


On Monday, 20 August 2018 at 11:38:39 UTC, Paul Backus wrote:
> Create an overload of foo that takes two arguments and combines 
> them into a `Data` struct internally:
>
> void foo(int a, string text)
> {
>     Data data = {a, text};
>     foo(data);
> }

Hmm, not very good solution. In C++ you can not to write type and 
compiler will deduce it automatically. In D, as I understand, 
this feature isn't supported.


More information about the Digitalmars-d-learn mailing list