
28 Jul
2010
28 Jul
'10
1:54 p.m.
I have an instance of ptr_map<int, classA>. I need to release an element from the map and use it somewhere else, making sure that it will not be deleted when the instance of ptr_map is deleted. I am successfully doing it with ptr_vectors, but can't get it right with ptr_map. What is the proper syntax of such call? I am doing it like in the code below, which does not compile. class classA {}; typedef ptr_map<int, classA> ptrmaptype; ptrmaptype val; val.insert(1, new classA()); ptrmaptype::mapped_type t = val.release (val.begin()); // I want "t" to be of classA* type