Created
July 25, 2011 09:58
-
-
Save jpf91/1103852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
import std.typecons; | |
void main() | |
{ | |
auto wrap1 = Wrapper(1); | |
} | |
void free(ref int _payload) | |
{ | |
writeln("dealloc"); | |
_payload = 0; | |
} | |
struct Wrapper | |
{ | |
struct Payload | |
{ | |
int _payload; | |
this(int h) { writeln("alloc"); _payload = h; } | |
~this() { free(_payload); } | |
this(this) { assert(false); } | |
void opAssign(Wrapper.Payload rhs) { assert(false); } | |
} | |
private alias RefCounted!(Payload, RefCountedAutoInitialize.no) Data; | |
private Data _data; | |
this(int h) { _data = Data(h); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment