Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 19, 2020 Should the compiler be failing to infer template args here? | ||||
---|---|---|---|---|
| ||||
If you take a look at this code here: https://godbolt.org/z/4T3uLh You can see that when using a templated alias, the compiler fails to infer the T template parameter, but only when using the function that also asks for the alias, instead of the original type. I was just wondering if this is correct behavior, since it's a slightly annoying, but easy to deal with difference. |
June 19, 2020 Re: Should the compiler be failing to infer template args here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to SealabJaster | On Friday, 19 June 2020 at 16:16:55 UTC, SealabJaster wrote: > If you take a look at this code here: https://godbolt.org/z/4T3uLh > > You can see that when using a templated alias, the compiler fails to infer the T template parameter, but only when using the function that also asks for the alias, instead of the original type. > > I was just wondering if this is correct behavior, since it's a slightly annoying, but easy to deal with difference. This is a known issue: https://issues.dlang.org/show_bug.cgi?id=1807 |
June 19, 2020 Re: Should the compiler be failing to infer template args here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote:
> This is a known issue:
>
> https://issues.dlang.org/show_bug.cgi?id=1807
"Reported: 2008"... yikes.
Thanks anyway, glad to know I wasn't just going mad :)
|
June 19, 2020 Re: Should the compiler be failing to infer template args here? | ||||
---|---|---|---|---|
| ||||
Posted in reply to SealabJaster | On 6/19/20 12:38 PM, SealabJaster wrote:
> On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote:
>> This is a known issue:
>>
>> https://issues.dlang.org/show_bug.cgi?id=1807
>
> "Reported: 2008"... yikes.
>
> Thanks anyway, glad to know I wasn't just going mad :)
It's somewhat difficult to solve, because reverse-templating is not necessarily one-to-one, or even have any tractible relationship at all.
Consider, for instance:
struct Foo(T) {}
alias Bar(T) = Foo!int;
void takefoo(X)(Bar!X) {}
takefoo(Foo!int());
How does the compiler decide what type T should be? It could be anything.
But this could be special cased for a *direct* alias translation. How to define that is tricky, but should match the pattern:
alias Template1(T) = Template2!(T, and, possibly, other, things)
Where Template2!(T, and, possibly, other, things) can be deduced for Template2 and T using IFTI directly.
As the age of that bug report shows, it's not easy to define or solve.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation