Defining some stuff for each class in turn

Phil Deets pjdeets2 at gmail.com
Thu Oct 1 18:17:15 PDT 2009


On Thu, 01 Oct 2009 12:53:46 -0500, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:
>
> interface Comparator(T)
> {
>      int opCmp(Comparator!T rhs);
>      mixin(Impl) // for each implementation Impl
>      {
>          int opCmp(Impl rhs);
>          override int opCmp(Comparator!T rhs)
>          {
>              return opCmp(cast(Impl) rhs);
>          }
>      }
> }
>

I like that you can use this in interfaces too. It seems to allow for  
something similar to multiple inheritance, but presumably without the  
implementation difficulty.

Phil Deets



More information about the Digitalmars-d mailing list