Skip to content

Instantly share code, notes, and snippets.

@jpf91
Created July 25, 2011 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpf91/1103852 to your computer and use it in GitHub Desktop.
Save jpf91/1103852 to your computer and use it in GitHub Desktop.
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