Vector of shared pointers , memory problems after clearing the vector
you have two copies of shared_ptr<A> in this case, one is the sharedptr variable and the other as an element in the vector. do this instead test.push_back(std::move(sharedptr)); note now the original sharedptr has it’s internal moved and no longer usable. The other thing is don’t do anything at all, this is a perfectly valid usage … Read more