In fact, since the template could be in a library, and code could use that library well after the library has been written... As such, there is a fundamental conflict between how templates work and how virtual functions work. They just don't mix.
Seems, the same problem doesn't allow auto attribute to virtual functions, because technically ,I think, possible get type from implemented functions, and if code trying to use return type not appropriate manner then throw runtime exception.
Like this: ``` interface I { auto foo(int i); } class A:I { string foo(int i) { return to!string(i); } } void fun(I instance) { auto a = instance.foo(1); // or even // string a = instance.foo(1); writeln(a[0..$/2]); writeln(a*5); //here will thrown exception } ```
What you can do is make final templates which aren't ever inherited but can forward to functions which can be inherited
That looks intresting, but little different from using virtual functions. I think it is mix interfaces and abstract classes.