[MS] Thoughts on creating a tracking pointer class, part 15: A custom shared pointer - devamazonaws.blogspot.com
Last time, we made our trackable object implementation's constructors and assignment operations non-throwing , although it came at a cost of making the act of creating a tracking pointer potentially-throwing. At the end, I noted that we didn't use all the features of C++ shared pointers. We never used weak pointers or thread safety, so we can replace shared pointers with a custom version that supports only single-threaded shared references. The single-threaded simplification is significant because it removes the need for atomic operations and allows the compiler to do reordering and coalescing of reference count manipulations. template<typename T> struct tracking_ptr_base { tracking_ptr_base() noexcept = default; tracking_ptr_base(tracking_ptr_base const& other) noexcept : m_ptr(other.copy_ptr()) {} tracking_ptr_base(tracking_ptr_base&& other) noexcept = default; ~tracking_ptr_base() = default; tracking_ptr_base& oper...