Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- auto Bar(IntT)(IntT val)
- {
- Bar!(IntT, IntT[]) bar;
- bar.payload = val;
- pragma(msg, "function IntT.stringof == "~IntT.stringof);
- return bar;
- }
- struct Bar(IntT, IntArr = IntT[])
- {
- IntT payload;
- pragma(msg, "struct IntT.stringof == " ~ IntT.stringof);
- }
- void main()
- {
- import std.stdio;
- auto bar1 = Bar(42); // IFTI for Foo constructor!
- auto bar2 = Bar("s"); // And for any type, too!
- auto bar3 = Bar('c');
- writefln("%d", bar1.payload); // 42
- writefln("%s", bar2.payload); // s
- writefln("%c", bar3.payload); // c
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement