Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- struct A {
- public:
- uint id;
- uint data[128];
- this(uint id) {
- this.id = id;
- writeln("CTor A with ", id);
- }
- this(this) {
- writeln("Postblit A with ", this.id);
- }
- ~this() {
- writeln("DTor A with ", this.id);
- }
- A opBinary(string op : "+")(ref const A a) {
- A r = A(this.id + a.id);
- r.data[] += a.data[];
- return r;
- }
- }
- void func(const A a) {
- writeln("Value call with A::", a.id);
- }
- void func(ref const A a) {
- writeln("Ref call with A::", a.id);
- }
- void main()
- {
- A a = A(42);
- A b = A(23);
- asm { int 3; }
- func(a + b);
- asm { int 3; }
- func(A(1337));
- func(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement