When does memory deallocation occur in the code below?
#include <memory>
int main()
{
auto p = std::make_shared<int>(5);
std::weak_ptr<int> wp = p;
p = nullptr;
return wp.lock() == nullptr ? 0 : 1;
}
As follows from this post std::make_shared
performs one heap-allocation. Does this mean that until at least one std::weak_ptr is alive the memory can't be deallocated?