Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Unique(T, Allocator = Mallocator) {
- private alias Alloc = TypedAllocator!Allocator;
- mixin SmartPtrMembers!T;
- @disable this();
- @disable this(this);
- @disable void opAssign();
- private void makeElement(Args...)(Args args) {
- mElement = Alloc.allocate!T();
- construct(mElement, args);
- }
- private this(EmptyInitializer) {
- makeElement();
- }
- private this(Args...)(auto ref Args args) if (Args.length > 0) {
- makeElement(args);
- }
- ~this() {
- destroyElement();
- }
- static typeof(this) make(Args...)(Args args) {
- static if (Args.length > 0) {
- return typeof(this)(args);
- } else {
- return typeof(this)(empty);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement