tuple of delegates requires explicit type

Meta jared771 at gmail.com
Wed Jun 20 12:00:27 UTC 2018


On Wednesday, 20 June 2018 at 11:43:52 UTC, DigitalDesigns wrote:
> alias f = void delegate();
> Tuple!(f)[] fs;
>
> fs ~= tuple(() { });
>
> fails but
>
> fs ~= Tuple!(f)(() { });
>
> passes.
> in tuple, it is seeing the lambda as void and thinks I'm trying 
> to append a tuple of void. I don't see why the compiler can't 
> see that it works.

It's because if you don't specify any types, the compiler creates 
a template function so type inference for the arguments/return 
type can take place. It could probably be inferred without making 
the literal a template, but that's just how it's done currently.


More information about the Digitalmars-d mailing list