For example, does the following leak?
Foo ( )
{
std:map<std:string, int> myMap;
myMap[std::string("Bar")] = 2983;
}
I believe it does not leak but can't find specific documentation on this point.
Yes, map destructor map::~map()
will call destructor for every key and value it manages and free memory.
§ 23.2.1 Table 96 — Container requirements (continued)
(&a)->X() void
the destructor is applied to every element of a; all the memory is deallocated.
Yes, it certainly does. This is pretty standard stuff in C++, and basically everything in the standard library and STL works this way--destructors are always called unless you're storing raw pointers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With