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.
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:
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:
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