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
- D templated codeblocks bpr
- Re: D templated codeblocks Araq
- Re: D templated codeblocks bpr
- Re: D templated codeblocks leorize
- Re: D templated codeblocks Sixte
- Re: D templated codeblocks bpr
- Re: D templated codeblocks treeform
- Re: D templated codeblocks juancarlospaco
- Re: D templated codeblocks mashingan
- Re: D templated codeblocks bpr
- Re: D templated codeblocks mratsim
