jeudi 23 juillet 2015

shared_ptr to std::vector of shared_ptr data destruction [duplicate]

This question already has an answer here:

Lets say I have a function which returns a smart pointer to a vector of smart pointers to some data.

shared_ptr<vector<shared_ptr<Data>> getVectorPtr();
auto vecPtr = getVectorPtr();

When vecPtr goes out of scope and is going to be destroyed do the shared_ptrs inside it also get deleted?

Just for knowledge: how does a smart pointer, internally, realizes it went out of scope?

Aucun commentaire:

Enregistrer un commentaire