lundi 3 décembre 2018

Is it useful to pass std::weak_ptr to functions?

I was reading this article by Herb Sutter about passing smart pointers to functions. He doesn't mention std::weak_ptr and honestly I can't find a good scenario where passing such smart pointer is useful.

Does the function take ownership? Pass std::shared_ptr. Does the function just need to operate on the underlying object? Pass a raw pointer or a reference.

So is passing std::weak_ptr to functions 100% useless?

Aucun commentaire:

Enregistrer un commentaire