Could anybody let me know where to find the source code (or sample code) of smart_ptr for reference counting?
I find the code for auto_ptr, but seems auto_ptr is not a REAL reference counting because it does not 'count'.
Printable View
Could anybody let me know where to find the source code (or sample code) of smart_ptr for reference counting?
I find the code for auto_ptr, but seems auto_ptr is not a REAL reference counting because it does not 'count'.
auto_ptr is a smart pointer, not a reference counting smart pointer. Check out boost (boost.org). They have a smart pointer library that includes shared_ptr, which is a reference counting smart pointer. In fact, shared_ptr and many of the other boost smart pointers have been added to TR1 which is an almost standard C++ library.
Or take a look at CountedPtr from here:
http://www.josuttis.com/
Use boost shared pointer or intrusive pointer.