Templates and virtual functions

Walter Bright newshound1 at digitalmars.com
Wed Jan 21 17:33:14 PST 2009


Robert Fraser wrote:
> If you're asking what I think ytou're asking; it's already there: mixins
> 
> class foo {
>      T nothing(T)(T arg) {  // Non-virtual.
>          return arg;
>      }
> 
>      mixin nothing!(int);    // Add nothing!(int) to foo's vtable.
>      mixin nothing!(float);  // Add nothing!(float) to foo's vtable.
>  }
> 
> You can override, whatever with them. You can't use the template syntax 
> to do an override, but... I'm not sure how much of a limitation this is.

Well, I'll be hornswoggled. I never thought of that!



More information about the Digitalmars-d mailing list