daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Nov 28th, 2018 108 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top