I feel confused about shared_ptr, and my main question is: does c++ create a new object (shared_ptr object) when I do the following?
void Func1(const shared_ptr<T>& rhs) {}
void Func2(const shared_ptr<const T>& rhs) {}
shared_ptr<T> v1;
Func1(v1);
Func2(v1);
Clearly, Func1(v1) is passed by ref. However, how about Func2(v1) ?
Will the complier does the following thing behind?
shared_ptr<const T> tmp_v2 = v1;
Func2(tmp_v2);
Thanks very much for your help!
Aucun commentaire:
Enregistrer un commentaire