lundi 28 novembre 2016

Is there a recommended way to test if a smart pointer is null?

I'm trying to check if a std::shared_ptr is null. Is there a difference between doing

std::shared_ptr<int> p;
if (!p) { // method 1 }
if (p == nullptr) { // method 2 }

Aucun commentaire:

Enregistrer un commentaire