I can insert with map like this:
std::map<int, int> testMap;
testMap.insert(std::make_pair(0, 1));
But if I surround the map with shared pointer like this:
std::shared_ptr<std::map<int, int>> testSharedMap;
testSharedMap->insert(std::make_pair(0, 1));
It doesn't work. I get a runtime error.
Exception thrown: read access violation.
_Scary was nullptr. occurred
How can I use the std::map
when it was surrounded by std::shared_ptr
?
Aucun commentaire:
Enregistrer un commentaire