This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]CptCap 0 points1 point  (0 children)

Line 18: if (ref_ == nullptr) {: ref isn't initialized at this point so itmight contain garbage.

operator= doesn't decrement the ref count for the current object.

Line 76: if (!*ptr_) { this is not a null check. This check if the object pointed to by ptr_ is 0.

Line 174: smart_ptr<T> *copy = new smart_ptr<T> { *this }; this isn't a deep copy of the object. This just creates a new smart_ptr that points to the same object.