On Tuesday, 3 July 2018 at 07:03:43 UTC, vit wrote:
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.
that's interesting, but I am using dsfml by jebbs( not derelict
), and I checked the code, it appears that the most of the class
allocates resource and then freeing it in Destructor i.e
class RenderWindow {
private sfRenderWindow* _window;
public {
this() {
_window = sfRenderWindow_create(/*parameters*/);
}
//couple of other functions
~this() {
sfRenderWindow_destroy( window );
}
}
}
//not a very accurate representation, but should get the message
pretty clear
which I am very concerned about leaking resources, the tutorial
did just not use scoped!, instead it directly use new, but what
about leaking resources ?