How does STL map deal with scoping and memory persistance



I am storing some key value pairs in a map as follows:

<code>
bool StaticDataCache::putMarket(uint8_t key,item_t* value)
{
typedef pair<uint8_t,item_t*> entry;
typedef map<uint8_t,item_t*>::iterator iter;

entry newEntry(key,value);
cout << "About to insert with key:" << key << endl;
pair<iter,bool> insertSuccess = marketsMap.insert(newEntry);

return true;
}
</code>

Now suprisingly to me this actually works when i was expecting it not
to. As you may notice the pair , newEntry, is local to this function,
which means, as i understand it, that once this function exits, the
memory used by newEntry is reclaimed and hence the pair inserted into
the map would be invalidated. Can anyone tell me why this is working.
Does the STL pair handle a 'new' behind the scenes??

.



Relevant Pages

  • Re: How does STL map deal with scoping and memory persistance
    ... As you may notice the pair, newEntry, is local to this function, ... > which means, as i understand it, that once this function exits, the ... > the map would be invalidated. ... All STL containers are value based. ...
    (microsoft.public.dotnet.languages.vc)
  • [PATCH] ext34: ensure do_split leaves enough free space in both blocks
    ... leaf block to make room for a new entry. ... It sorts the entries in the ... The dx_map "offs" member is reduced to u16 so that the overall map ... * Returns pointer to last entry in range. ...
    (Linux-Kernel)
  • [27/50] ext34: ensure do_split leaves enough free space in both blocks
    ... block to make room for a new entry. ... It sorts the entries in the original ... The dx_map "offs" member is reduced to u16 so that the overall map size ... * Returns pointer to last entry in range. ...
    (Linux-Kernel)
  • Re: RPCA Map Deletions
    ... >correction and left her "second correction" entry. ... >Please let me know (and under what entry title on the map since some of you ... ~Karen aka Kajikit ...
    (rec.pets.cats.anecdotes)
  • Re: Generics on map.
    ... But the very idea of generics is to avoid these runtime mistakes ... that you don't insert a String key into a Map that expects only ... no such entry exists. ...
    (comp.lang.java.programmer)