The destructor of T2 is called nowhere in this example, only the pointer is destroyed. When the map is out of scope, it will destroy all pairs of elements <T1, T2*>, but this will not call delete on the second item.
You could however use boost::shared_ptr or std::shared_ptr (C++11) if you want reference-counted pointers.
#include <boost/shared_ptr.hpp> std::map <T1, boost::shared_ptr<T2> > my_map; T1 t; T2 *tt = new T2; my_map[t] = tt; // tt is passed to a shared_ptr, ref count = 1 // when out of scope, the destructor of `boost::shared_ptr` will call `delete`.
If you needn't make copies of the objects stored in the map, you can use C++11's std::unique_ptr.