Murray's Blog

C++ reference-counting smart pointers

;I finally took the time to figure out how to implement C++ reference-counting smart pointers: Of course you just
copy a
pointer to a counter in the copy constructors. And, by
adding an allocator type to the template specification, it
can even be used to wrap C types that have special
allocation and deallocation functions, without repetition of
code in the derived classes. This has been on my TODO list
for so long that I feel an overwhelming sense of well being
from having found such a simple solution.

Exit mobile version