Why unique_ptr can take owership of a const ptr? What is the meaning of unique_ptr < const T>?
std::unique_ptr<int> a(new int);
// Only this is compile error.
std::unique_ptr<int> b((const int*)new int);
std::unique_ptr<const int> c(new int);
// Why unique_ptr can take a const ptr, and delete it when deconstruct?
std::unique_ptr<const int> d((const int*)new int);
Tested with g++ 4.8
Aucun commentaire:
Enregistrer un commentaire