dimanche 16 décembre 2018

Why can std::map::emplace usage leak memory?

In a recent article I read that the following use of std::map::emplace might leak memory, but I do not see why:

// might leak if allocation fails due to insufficient memory for an object A
std::map<int, std::unique_ptr<A>> m;
m.emplace(1, std::make_unique<A>("Ann",63));

Can anybody explain?

Aucun commentaire:

Enregistrer un commentaire