Re: Question about STL containers in multithreaded environment



gioparl wrote:

I didn't know that...
so the good way is:

const iteraror=map.find(key);
if(iterator!=map.end())
return iterator->second;
or also I have to make a const alias to map also ??

All STL containers is allowed (but it is not obligatory) to have
reference counted implementation to optimize copying and swaping
operations (especially for std::string-s). So one cannot guarantee that
if you invoke non-const method you container will not be changed. You
has to make const alias in your case also.

.



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)
  • Re: unique value for map
    ... tyep which allows same. ... All STL containers (and a lot of non-STL ones) would allow you to insert ... can insert the same element into a linked list and also into a map, ...
    (microsoft.public.vc.stl)
  • Re: CComBSTR, std::endl and stack overflow
    ... be using CComBSTR in a map because STL containers have specific ... you are not allowed to put CComBSTR into any STL container. ... Doing so invokes undefined behavior. ... but not with map. ...
    (microsoft.public.vc.atl)
  • Re: map and vector
    ... > How could I create a map that contains a CString as a key and ... > I have some vector with some data and want to map it to associative ... > What's wrong with my understanding of stl containers? ... you can store the index (unsigned int) of the vector into map. ...
    (microsoft.public.vc.stl)

Loading