isPseudoInterface

using:

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

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

Members

Functions

checkMembers
bool checkMembers()
Undocumented in source. Be warned that the author may not have intended to support it.
fail
bool fail(string fmt, Args args)
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

isPseudoInterface
enum isPseudoInterface;
Undocumented in source.

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 ) );
interface A
{
    void func1( int );
}

class B : A
{
    void func1( int ) {}
    int func2( string ){ return 0; }
}

struct Cfunc1 { void opCall( int ) { } }

interface iB: A
{
    int func2( string );
}

struct C
{
    Cfunc1 func1;
    int func2( string ){ return 0; }
}

assert( !isPseudoInterface!( B, C,false ) );
assert(  isPseudoInterface!( iB, C,false ) );

Meta