digitalmars.D.learn - Should the compiler be failing to infer template args here?
- SealabJaster (7/7) Jun 19 2020 If you take a look at this code here: https://godbolt.org/z/4T3uLh
- Paul Backus (3/11) Jun 19 2020 This is a known issue:
- SealabJaster (3/5) Jun 19 2020 "Reported: 2008"... yikes.
- Steven Schveighoffer (16/24) Jun 19 2020 It's somewhat difficult to solve, because reverse-templating is not
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.
Jun 19 2020
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
Jun 19 2020
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 :)
Jun 19 2020
On 6/19/20 12:38 PM, SealabJaster wrote:On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote: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. -SteveThis 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 :)
Jun 19 2020