View difference between Paste ID: 8zVWmxrT and qi81d0W4
SHOW: | | - or go back to the newest paste.
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-
struct Object1
10+
11
template IsInheriting( Base, T )
12-
	int foo;
12+
13
	static if( is( T.BaseTypes ) )
14
	{
15-
struct Object3
15+
		bool Inherits()
16
		{
17-
	int notFoo;
17+
			bool inherits = is( T == Base );
18
			static foreach( ST; T.BaseTypes )
19
			{
20-
struct Object2
20+
				inherits |= IsInheriting!( Base, ST );
21
			}
22-
	mixin Inherits!( Object1, Object3 );
22+
			return inherits;
23-
	int bar;
23+
		}
24
		enum IsInheriting = Inherits();
25
	}
26-
pragma( msg, Object2.init.foo );
26+
	else
27
	{
28
		enum IsInheriting = false;
29
	}
30
}