digitalmars.D.learn - Help with DynamicArray of Emsi Containers
- =?UTF-8?Q?Christian_K=c3=b6stlin?= (44/44) Apr 30 2022 I am struggling with initializing an Emsi Containers DynamicArray in a
- vit (9/56) May 01 2022 DynamicArray has disabled postblit (is not copyable).
- =?UTF-8?Q?Christian_K=c3=b6stlin?= (3/12) May 01 2022 Thanks a lot for those pointers, I changed/upgraded my dependencies, and...
I am struggling with initializing an Emsi Containers DynamicArray in a nice way. Some background information of my usecase: I experimenting in porting some old 3d engine code of mine from c++ to dlang. In the engine I want to exactly control when resources are freed and not rely on the garbage collector. For that I am using reference counters courtesy of autoptr. e.g. ```d alias Texture = IntrusivePtr!TextureData; // dub package autoptr class TextureData { IFImage image; // dub package imagefmt } ``` another class of mine now is supposed to hold several of those textures for multitexturing and should be initialized in its constructor: ```d class Appearance { Texture[] textures; this(Texture[] textures) { this.textures = textures; } } ``` Unfortunately this does not work properly together with autoptr's (see https://github.com/submada/autoptr/issues/5#issuecomment-997683868). Because of that I am using now DynamicArrays from Emsi Containers, but I am having trouble initializing them: ```d class Apperance { DynamicArray!Texture textures; this(DynamicArray!Texture textures) { this.textures = textures; } } ``` does not compile. What would be the best way to initialize the variable? Kind regards, Christian
Apr 30 2022
On Saturday, 30 April 2022 at 20:22:43 UTC, Christian Köstlin wrote:I am struggling with initializing an Emsi Containers DynamicArray in a nice way. Some background information of my usecase: I experimenting in porting some old 3d engine code of mine from c++ to dlang. In the engine I want to exactly control when resources are freed and not rely on the garbage collector. For that I am using reference counters courtesy of autoptr. e.g. ```d alias Texture = IntrusivePtr!TextureData; // dub package autoptr class TextureData { IFImage image; // dub package imagefmt } ``` another class of mine now is supposed to hold several of those textures for multitexturing and should be initialized in its constructor: ```d class Appearance { Texture[] textures; this(Texture[] textures) { this.textures = textures; } } ``` Unfortunately this does not work properly together with autoptr's (see https://github.com/submada/autoptr/issues/5#issuecomment-997683868). Because of that I am using now DynamicArrays from Emsi Containers, but I am having trouble initializing them: ```d class Apperance { DynamicArray!Texture textures; this(DynamicArray!Texture textures) { this.textures = textures; } } ``` does not compile. What would be the best way to initialize the variable? Kind regards, ChristianDynamicArray has disabled postblit (is not copyable). Package autoptr is deprecated (internaly redirected to btl:atuoptr), all functionality is moved to package [BTL](https://code.dlang.org/packages/btl) (subpackage btl:autoptr). This library contains subpackage btl:vector with functionality like DynamicArray with support for copying. I use IntrusivePtr inside Vector/SmallVector and i have no problems.
May 01 2022
On 2022-05-01 09:12, vit wrote:DynamicArray has disabled postblit (is not copyable). Package autoptr is deprecated (internaly redirected to btl:atuoptr), all functionality is moved to package [BTL](https://code.dlang.org/packages/btl) (subpackage btl:autoptr). This library contains subpackage btl:vector with functionality like DynamicArray with support for copying. I use IntrusivePtr inside Vector/SmallVector and i have no problems.Thanks a lot for those pointers, I changed/upgraded my dependencies, and it already looks better.
May 01 2022