When I check the "improved" version of the smart pointer, I need to increase the reference count. I see that they use some “sophisticated” methods for link counting, for example. a completely separate class or pointer pointing to an integer.
Here is one example:
template<class T> class SmartPointer{ T* mp_T; unsigned int * mp_Count; public: ... all the APIs ... };
I wonder what is a win? Since the goal is for all instances to share the value, why not just declare it as a static member variable:
template<class T> class SmartPointer{ T* mp_T; static unsigned int m_Count; public: ... all the APIs ... };
I need to skip something, but after some searching, I can not find the answer. Enlighten the light.
source share