smart_ptr icon indicating copy to clipboard operation
smart_ptr copied to clipboard

bugfix:smart_ptr拷贝函数实现

Open Playerfff opened this issue 10 months ago • 0 comments

template <typename T> smart_ptr<T>::smart_ptr(const smart_ptr& rhs) :m_pobject(rhs.m_pobject), m_p_use_count(rhs.m_p_use_count), m_del(rhs.m_del) { (*m_p_use_count)++; } 如果调用这个函数,例如:smart_ptr<T> ptr2(ptr1); 只有ptr2的引用计数会加1,ptr1的引用计数没变,我觉得有问题,应该ptr1和ptr2使用一块memory作为引用计数,确保ptr2在增加引用计数时ptr1的引用计数也会变。

Playerfff avatar Apr 15 '24 06:04 Playerfff