I'm obviously not that good at explaining things. Here's a bit more D, to flesh 
out the example
    
    
    import std.stdio;
    
    template MyTemplate(T) {
        T val;
        
        void copy(out T to, T from) {
            to = from;
        }
        
        struct Node {
            T v;
            Node* left;
            Node* right;
        }
    }
    
    int main() {
        writefln("hello world\n");
        MyTemplate!(int).val = 666;
        MyTemplate!(string).val = "Hello";
        writefln("val = %d and val = %s\n",
               MyTemplate!(int).val,
               MyTemplate!(string).val);
        MyTemplate!(int).copy(MyTemplate!(int).val, 42);
        writefln("val = %d and val = %s\n",
               MyTemplate!(int).val,
               MyTemplate!(string).val);
        return 0;
    }
    
    
    Run

Reply via email to