isPseudoInterface

using:

void func(T)( T v ) if( isPseudoInterface(Interface,T) ) { }

template isPseudoInterface (
I
T
bool _assert = true
string FILE = __FILE__
int LINE = __LINE__
) {
enum isPseudoInterface;
}

Examples

1 interface IFace
2 {
3     void func1( int );
4     size_t func2( string );
5 }
6 
7 struct Afunc1 { void opCall( int ){} }
8 struct Afunc2 { size_t opCall( string ){ return 0; } }
9 
10 class A
11 {
12     Afunc1 func1;
13     Afunc2 func2;
14 }
15 
16 struct B
17 {
18     void func1( int ) { }
19     size_t func2( string str ) { return 0; }
20 }
21 
22 class C
23 {
24     void func1( int ) { }
25     size_t func2( string str ) { return 0; }
26 }
27 
28 class D: A
29 {
30     void func1( int ) { }
31     size_t func2( string str ) { return 0; }
32 }
33 
34 class E
35 {
36     int func1;
37     size_t func2( string str ){ return 0; }
38 }
39 
40 class F
41 {
42     void func1() { }
43     size_t func2( string str ){ return 0; }
44 }
45 
46 class G
47 {
48     void func1( in int ){}
49     size_t func2( string str ){ return 0; }
50 }
51 
52 static assert(  isPseudoInterface!( IFace,A,false ) );
53 static assert(  isPseudoInterface!( IFace,B,false ) );
54 static assert(  isPseudoInterface!( IFace,C,false ) );
55 static assert(  isPseudoInterface!( IFace,D,false ) );
56 
57 static assert(  isPseudoInterface!(A,C,false) );
58 
59 static assert( !isPseudoInterface!( IFace,E,false ) );
60 static assert( !isPseudoInterface!( IFace,F,false ) );
61 static assert( !isPseudoInterface!( IFace,G,false ) );
1 interface A
2 {
3     void func1( int );
4 }
5 
6 class B : A
7 {
8     void func1( int ) {}
9     int func2( string ){ return 0; }
10 }
11 
12 struct Cfunc1 { void opCall( int ) { } }
13 
14 interface iB: A
15 {
16     int func2( string );
17 }
18 
19 struct C
20 {
21     Cfunc1 func1;
22     int func2( string ){ return 0; }
23 }
24 
25 assert( !isPseudoInterface!( B, C,false ) );
26 assert(  isPseudoInterface!( iB, C,false ) );

Meta