Regarding type deduction

bearophile bearophileHUGS at lycos.com
Mon Sep 17 07:55:34 PDT 2012


Do you think it's useful and possible to extend the D type 
inference (deduction) for templates to support something like 
this (I know there are different ways to do this in D)?


struct Tree1 {
     static struct Node { int x; }
}
struct Tree2 {
     static struct Node { int x, y; }
}
void foo(T)(T.Node n1, T.Node n2) {} // ***
void main() {
     Tree1.Node n1, n2;
     foo(n1, n2);
}


(I am asking this because nested types are becoming increasingly 
common in D code.)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list