automem v0.0.7 - C++ style smart pointers using std.experimental.allocator

Stanislav Blinov via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Apr 17 06:33:23 PDT 2017


On Monday, 17 April 2017 at 13:21:50 UTC, Kagamin wrote:

> If we can control memory layout, we can do what shared_ptr does 
> and couple the reference counter with the object, then we can 
> have just one pointer:
>
> struct RefCounted(T)
> {
>   struct Wrapper
>   {
>     int count;
>     T payload;
>   }
>   Wrapper* payload;
> }

I'm not sure I follow your comment. Indeed, that is how 
shared_ptr, or, in this case, RefCounted, is implemented. My 
point was that there is no practical sense in having a 
shared(RefCounted).


More information about the Digitalmars-d-announce mailing list