Advertisement
Guest User

Untitled

a guest
Nov 28th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mixin Inherits( T... )
  2. {
  3.     alias BaseTypes = Alias!T;
  4.     static foreach( Index, ST; T )
  5.     {
  6.         mixin( "ST base" ~ Index.to!string ~ ";" );
  7.     }
  8.     alias base0 this;
  9. }
  10.  
  11. template IsInheriting( Base, T )
  12. {
  13.     static if( is( T.BaseTypes ) )
  14.     {
  15.         bool Inherits()
  16.         {
  17.             bool inherits = is( T == Base );
  18.             static foreach( ST; T.BaseTypes )
  19.             {
  20.                 inherits |= IsInheriting!( Base, ST );
  21.             }
  22.             return inherits;
  23.         }
  24.         enum IsInheriting = Inherits();
  25.     }
  26.     else
  27.     {
  28.         enum IsInheriting = false;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement