Should the compiler be failing to infer template args here?

Steven Schveighoffer schveiguy at gmail.com
Fri Jun 19 17:03:25 UTC 2020


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


More information about the Digitalmars-d-learn mailing list