Re:Why I Chose to Learn C
by pjmlp on Saturday March 30, 2013 @02:51AM
(#5464696)
I fail to see how that is not reference counting, even if implemented at library level.
[ Parent
| on HN ]
shared_ptr probably does use reference counting, but unique_ptr doesn't.
There's literally only ever one "owner" of a unique_ptr, which is why the parent comment talked about taking it from somewhere.
C++ exchanges ownership of unique_ptr's in the move constructor or assignment operator (i.e. there's no "copy" operation available, unlike with std::auto_ptr). If a unique_ptr still happens to own a pointer when the unique_ptr is destructed, it knows to destroy the pointed-to object as well and free the memory, but the object itself is not reference-counted per se, there's only the Boolean sense "alive/dead".
That is still reference counting in any CS book about automatic memory management algorithms.
Only in the sense that
MOV EAX, EBP
XOR EBP, EBP
is "reference counting".