jeudi 25 novembre 2021

Is it possible that `shared_ptr::use_count() == 0` and `shared_ptr::get() != nullptr`?

From the cppref:

Notes

An empty shared_ptr (where use_count() == 0) may store a non-null pointer accessible by get(), e.g. if it were created using the aliasing constructor.

Is it possible that shared_ptr::use_count() == 0 and shared_ptr::get() != nullptr?

Any example to illustrate that is true?

Aucun commentaire:

Enregistrer un commentaire