D RAII with postblit disabled

Norm norm.rowtree at gmail.com
Tue Mar 27 02:35:23 UTC 2018


Hi All,

What's the best way to do this in D?

E.g.

---
struct O
{
   int* value;
   @disable this(this);
/+
   this()
   {
     this.value = theAllocator.make!int(99);
   }
+/
   ~this()
   {
     theAllocator.dispose(this.value);
   }
}

O obj = O(); // Ideally this would be allocated but it simply run 
O.init
---

Thanks
Norm


More information about the Digitalmars-d-learn mailing list