Function template parameter inference from class template
Justin Johansson
procode at adam-dott-com.au
Wed Sep 23 16:39:28 PDT 2009
Jarrett Billingsley Wrote:
> > I don't know if it would be pushing my luck or not, but is your concept generalizable to more parameters. In particular I want to be able to extend this so than bar() can return a generic type.
> >
>
> class Foo(T)
> {}
>
> R bar(R, T : Foo!(U), U)(T t)
> {
> R r;
> return r;
> }
>
> void main()
> {
> auto foo = new Foo!(float)();
> auto chu = bar!(double)(foo);
> pragma(msg, typeof(chu).stringof);
> }
>
> Make sure you have a newer compiler, though, as partial template
> specialization with IFTI was only introduced in DMD 1.038.
Thanks again. I tried that before posting and it didn't work. Checked my DMD version .. missed out by 0.001 .. I had DMD 1.037.
Upgraded just now to DMD 1.047 and your solution rocks yet again :-)
<JJ/>
More information about the Digitalmars-d
mailing list