mercredi 24 janvier 2018

Whether iterator can add shared_ptr's count?

For example:

#include <memory>

shared_ptr<map<int, int>> ptr1 = make_shared<map<int, int>>();
map<int, int>::const_iterator iter = ptr1->begin();
shared_ptr<map<int, int>> ptr2 = make_shared<map<int, int>>();
ptr1 = ptr2;

My question: Could the iter add the counts of ptr1? In this case, will the ptr1's memory address free?

Aucun commentaire:

Enregistrer un commentaire