Two suggestions for safe refcounting

monarch_dodra via Digitalmars-d digitalmars-d at
Fri Mar 6 06:59:45 PST 2015

On Friday, 6 March 2015 at 07:46:13 UTC, Zach the Mystic wrote:
> The second, harder problem, is when you take a reference to a 
> subcomponent of an RC'd type, e.g. an individual E of an 
> RCArray of E:
> struct RCArray(E) {
>   E[] array;
>   int* count;
>   ...
> }
> auto x =  RCArray([E()]);
> E* t = &x[0];

But taking that address is unsafe to begim with. Do arguably, 
this isn't that big of a problem.

Your first dual reference issue seems much more problematic, as 
there are always cases the compiler can't catch.

More information about the Digitalmars-d mailing list