how to create an array of scoped objects ?
vit
vit at vit.vit
Tue Jul 3 07:03:43 UTC 2018
On Tuesday, 3 July 2018 at 02:13:21 UTC, Flaze07 wrote:
> 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 ?
Copying/moving scoped!Class is very unsafe. scoped!Class is
struct and have all of limitations of structs like no internal
pointers to itself...
That's why it is not copyable.
More information about the Digitalmars-d-learn
mailing list