I was wondering if the implicit cast I have when passing a shared_ptr < T>& as argument to a function taking shared_ptr < const T>& involves some hidden costs (such as the construction of a copy).
void f(shared_ptr<const T>& )
main{
auto p = make_shared<Widget>();
f(p);
return 0;
}
Similarly I was wondering if I have an extra cost when passing shared_ptr < T> instead of shared_ptr < const T>. (I'm assuming that in both cases I am paying for the refcount increment and decrement).
Aucun commentaire:
Enregistrer un commentaire