Menu
Home
Create new Paste
Log in
Code
Theme: cobalt
Theme: eclipse
Theme: elegant
Theme: monokai
Theme: neat
Theme: night
Theme: rubyblue
import std.stdio; struct Unique(T) { private: T _val; public: this(T val) { this._val = val; } this(ref T val) { this._val = val; val = null; } this(ref Unique!(T) uni) { this._val = uni._val; uni._val = null; } ~this() { .destroy(this._val); this._val = null; } version (all) { immutable(T) opDot() immutable pure nothrow { return this._val; } } else { @property immutable(T) get() immutable pure nothrow { return this._val; } alias get this; } bool isValid() const pure nothrow { return this._val !is null; } Unique!(T) move() { return Unique!(T)(this); } } class A { } void main() { Unique!(A) uni = new A(); }
Result:
Success
/
Return code: 0
/
Compilation time:
0.838
seconds
/
Run time:
0.001
seconds
Disassembly
Username
Message
Add comment
Paste info
Author:
Namespace
Views:
107
Private:
no
Expires:
Never
Uploaded:
11.11.12 21:10
Votes
:
0
Tweet
Compilation
Compiler:
DMD 2.060
Pointer size:
m64
Actions
Download
Fork
Raw
×
Confirm
Are you sure you want to delete this paste?
There's no way back!
×
Confirm
Reason