Trying to implement a reference counting mechanism

Martin martinbbjerregaard at gmail.com
Tue Mar 19 15:13:12 PDT 2013


On Tuesday, 19 March 2013 at 22:09:22 UTC, Brad Anderson wrote:
> On Tuesday, 19 March 2013 at 22:06:31 UTC, Martin wrote:
>> http://pastebin.com/8M2EuyfT
>>
>> I'm fairly new to D, but would this work? Obviously I would 
>> need to make my own kind of associative array that uses manual 
>> memory management to completely circumvent the GC, but besides 
>> that?
>
> Have you seen std.typecons.RefCounted[1]?  If you are just 
> looking to learn more so than get a RefCounted class you could 
> take some idea's from its source code[2].
>
> [1] http://dlang.org/phobos/std_typecons.html#.RefCounted
> [2] 
> https://github.com/D-Programming-Language/phobos/blob/master/std/typecons.d#L2644

Yes, I have indeed studied the RefCounted struct in std.typecons. 
Unfortunately it only works with structs, not classes. I just 
wanted to try a different approach to see if it would work


More information about the Digitalmars-d-learn mailing list