Boost logo

Boost Users :

Subject: Re: [Boost-users] how to release element from ptr_map?
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2010-07-28 11:41:04

archie14 skrev:
> 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


   ptrmaptype::auto_type ptr = val.release(val.begin());

not work??

Then you can call ptr.release() to get the naked ptr.



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at