Scoped Class Instance

2012-01-31 Thread Zachary Lund
I've been looking into (basic) memory management within D. Through IRC conversation and reading the article on memory management on dlang.org (which seems to be a bit out-of-date), I've concluded that using a global (or static member) function and emplace() in std.conv is a simple solution for

Re: Scoped Class Instance

2012-01-31 Thread Nicolas Silva
You can use structs for this kind of problems, somethin like struct Scoped(T) { ~this() { //handle deallocation here } T inst; } if you create a Scoped!MyClass in a scope, the struct's destructor will be invoked whenever the program leaves the scope, even if it is because

Re: Scoped Class Instance

2012-01-31 Thread Trass3r
However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped

Re: Scoped Class Instance

2012-01-31 Thread Zachary Lund
On Tuesday, 31 January 2012 at 15:19:00 UTC, Trass3r wrote: However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped I looked into this and I'm unsure of its exact use. It says, Allocates a class object right inside the current scope which doesn't really

Re: Scoped Class Instance

2012-01-31 Thread Simen Kjærås
On Tue, 31 Jan 2012 16:42:52 +0100, Zachary Lund ad...@computerquip.com wrote: On Tuesday, 31 January 2012 at 15:19:00 UTC, Trass3r wrote: However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped I looked into this and I'm unsure of its exact use. It