how to create an array of scoped objects ?

Flaze07 christianseiji.cs at gmail.com
Tue Jul 3 02:13:21 UTC 2018


e.g A is a class that emits output during destruction
{
     auto a = scoped!A();
}

how do I contain it in a container, in the Array struct ?

{
     auto a = scoped!A();
     Array!( typeof( a ) ) arr;
     foreach( i ; 0..3 ) {
         arr.insertBack( scoped!A );
     }
}

is that how you do it ?


More information about the Digitalmars-d-learn mailing list