Steven Schveighoffer Wrote:
> > perhaps it is depends on the language version.
> > At least both DMD 2.030 and 1.045 reject your suggestion.
> I think possibly I compiled without instantiating the template, and that's
> why it worked...
My code is here:
interface I
{
void f(int);
void f_twice()() { f(1); f(1); }
}
class C : I
{
void f(int i) { }
}
void main() {
(new C).f_twice();
}
For this code DMD said Error: function I.f_twice!().f_twice template member
function not allowed in interface I
I would like to know the code is proper for my purpose.
> Templates do not go into the vtable, and are essentially final. So it would
> be a legal solution. It would also be nice to be able to have the ability to
> do templates in an interface.
>
> Your suggestion for final functions may also be a possible solution, but I
> see one caveat: If the function overrides a base-interface's non-final
> function, then the function has to go into the base-interface's vtable, which
> is probably not correct.
thanks for your explanation.
my suggestion is not better because check code for the final function in the
inherited interface make the compiler be complex, which violates D's policy.