What is the advantage of using the using a unique_ptr destructor over just closing the file directly in C++11?
i.e. this code
FILE* p = fopen("filename","r");
unique_ptr<FILE, int(*)(FILE*)> h(p, fclose);
if (fclose(h.release()) == 0)
p = nullptr;
vs.
FILE* p = fopen("filename","r");
fclose(p)
Aucun commentaire:
Enregistrer un commentaire