First Draft: Implicit Type Template Instantiation via Constructors
Meta
jared771 at gmail.com
Wed Mar 12 03:18:14 UTC 2025
On Wednesday, 12 March 2025 at 02:37:06 UTC, jmh530 wrote:
> On Wednesday, 12 March 2025 at 00:20:55 UTC, Meta wrote:
>> This DIP is a partial resurrection of DIP 40
>> (https://wiki.dlang.org/DIP40) by me and Dennis Korpel. Dennis
>> is working on the implementation
>> (https://github.com/dlang/dmd/pull/16910) while I am writing
>> the DIP.
>>
>> [...]
>
> Glad to see someone working on this problem.
>
> How would this apply to template aliases (e.g. DIP1023)?
From my understanding, it should work the same way as IFTI, i.e.,
if eventually this code compiles:
```d
struct TemplateType(T) { }
alias TemplateAlias(T) = TemplateType!T;
void templateFunction(T)(TemplateAlias!T arg) { }
void main()
{
TemplateAlias!int ta;
templateFunction(ta);
}
```
Then this code should as well:
```d
struct TemplateType(T) { }
alias TemplateAlias(T) = TemplateType!T;
struct AnotherTemplateType(T)
{
this(TemplateAlias!T arg) {}
}
void main()
{
TemplateAlias!int ta;
auto att = AnotherTemplateType(ta); // Currently does not
compile, even if you add
AnotherTemplateType!(TemplateAlias!int)(ta)
}
```
More information about the dip.development
mailing list