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'.
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/
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Use boost shared pointer or intrusive pointer.