std::map <int, std::shared_ptr<A>> m; std::shared_ptr<A> *a = &m[2]; std::shared_ptr<A> *b = &m[2]; m.erase(2); if(a) std::cout << "exist a\n"; if(b) std::cout << "exist b\n"; Is it possible to somehow find out with minimal costs (there are many elements in the map) does m [2] exist? Is it possible to somehow know this through a and b? Is it possible to somehow reset / delete the memory to which they refer and thus to perform the verification when deleting m [2]?
shared_ptr... Not in the sense of language capabilities, but in the sense of design, of course ... - Harryshared_ptritself was created to get rid of pointers. By the way, the proposed solution does not use them! Therefore, the pointer toshared_ptr... well, since you are in a bottle and you didn’t like my polite comment, so be it, I will tell you straight - the decision is stupid. And yet - do not tell me what I can write and what not, and I will not tell you where to go. To everyone who reads: forgive me generously, if there was a person there, I would write there, and you have to read it ... :( - Harry