On Saturday, 6 February 2016 at 17:36:28 UTC, Ola Fosheim Grøstad
wrote:
On Saturday, 6 February 2016 at 17:22:03 UTC, Adam D. Ruppe
wrote:
On Saturday, 6 February 2016 at 11:15:06 UTC, Ola Fosheim
Grøstad wrote:
Nothing prevents you from creating your own reference
counting mechanism.
A struct wrapper doesn't give the things you need to reliably
handle inheritance.
I don't think I suggested using a struct wrapper? :-) That just
cause issues with alignment or requires a more complex
allocator.
You can either build the refcount into the root class or use an
extra indirection like C++'s shared_ptr.
Can't be done with the root class because classes never trigger
RAII outside of (deprecated) scope allocations.
Can't be done with indirection because you still hit the same
issue.
Applies to storage classes aswell, btw.