scope(~this)
    Ali Çehreli via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Wed Mar 15 12:34:32 PDT 2017
    
    
  
On 03/15/2017 03:23 AM, Basile B. wrote:
 > you can use a mixin template because
 > they can introduce destructors that are called automatically with the
 > aggregate destrcutor
 >
 > mixin template Foo(T)
 > {
 >     T x;
 >     void foo()
 >     {
 >         alloc(x);
 >     }
 >     ~this() // auto-called by the target aggregate
 >     {
 >         dealloc(x);
 >     }
 > }
 >
 > class bar
 > {
 >     mixin Foo!Stuff;
 > }
Wow! Is this specified anywhere or have you come across this by chance? :)
Ali
    
    
More information about the Digitalmars-d-learn
mailing list