Inferring function argument types from other argument types

bearophile bearophileHUGS at lycos.com
Mon Nov 12 05:02:04 PST 2012


Joseph Rushton Wakeling:

> Full example code attached, just for clarity.


Like this?


T2 func(T, T2)(T foo, T2 x) if (is(T2 == T.T1)) {
     return x * foo.a;
}

void main() {
     auto foo = new Foo!(size_t, real)(3, 2.5);
     size_t y = 4;
     writeln(foo.func(y));
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list