Boost logo

Boost Users :

Subject: [Boost-users] how to release element from ptr_map?
From: archie14 (admin_at_[hidden])
Date: 2010-07-28 09:54:15


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net