天天看点

d版静态函数作插件

import core.stdc.stdio : printf;

struct C {
    static void f() {
        printf("C\n");
    }
}

struct D {
    static void g() {
        printf("D\n");
    }
}

struct B(C,D){
    void sayHello() {
        printf("hello\n");
        C.f();D.g();
    }
}

extern (C) void main() {
    B!(C,D) b;
    b.sayHello();
}      
import core.stdc.stdio : printf;

void f(int I)() {
    printf("C\n");
    printf("%i",I);
}

void g(I)() {
    printf("D\n");
    printf(I.stringof);
}

void sayHello(alias F,alias G,int I)() {
    printf("hello\n");
    F!I();G!string();
}

extern (C) void main() {
    sayHello!(f,g,4)();
}