Click here to Skip to main content
16,005,491 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: reading a text document (I hope this is the right place :) ) Pin
jhaga15-May-03 7:41
professionaljhaga15-May-03 7:41 
GeneralMainFrame :o) Pin
MemLeak15-May-03 6:00
MemLeak15-May-03 6:00 
GeneralRe: MainFrame :o) Pin
David Crow15-May-03 6:37
David Crow15-May-03 6:37 
GeneralRe: MainFrame :o) Pin
peterchen15-May-03 20:35
peterchen15-May-03 20:35 
GeneralRe: MainFrame :o) Pin
David Crow16-May-03 3:40
David Crow16-May-03 3:40 
GeneralRe: MainFrame :o) Pin
peterchen16-May-03 3:49
peterchen16-May-03 3:49 
GeneralSTL: reference to map items Pin
peterchen15-May-03 5:51
peterchen15-May-03 5:51 
GeneralRe: STL: reference to map items Pin
Joseph Dempsey15-May-03 7:55
Joseph Dempsey15-May-03 7:55 
Take w/ grain of salt: Poke tongue | ;-P

I am not 100% about this but i wouldn't think that your reference is going to hold all the time. Some % of the time it may be valid but others it wouldn't. I would have to look at the stl implementation but i am guessing that if you insert an element and the map object has to rehash to fit the element in the pair reference is going to be invalidated. However if the map does not have to be rehashed than there is a chance that the reference remains valid. When i have to do something like what you are doing i ususally use pointers to my structures so that you can do:

somestruct* p = map.find( .. ).second;


One issue you are going to have though as far as reading back map elements is that a map doesn't promise to maintain your insertion order whatsoever ( in most cases anyway. I don't think std::map does either, though it could be forced somehow by providing a sort function ).

Joseph Dempsey
joseph_r_dempsey@yahoo.com

"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
GeneralRe: STL: reference to map items Pin
jbarton15-May-03 8:57
jbarton15-May-03 8:57 
Generalthanks! Pin
peterchen15-May-03 20:33
peterchen15-May-03 20:33 
General.Net and "edit and continue" Pin
ns15-May-03 5:41
ns15-May-03 5:41 
GeneralAIM104-Relay8/In8 Pin
Bernhard15-May-03 3:57
Bernhard15-May-03 3:57 
GeneralNeed help with DLL Pin
AnTri15-May-03 3:51
AnTri15-May-03 3:51 
GeneralRe: Need help with DLL Pin
David Crow15-May-03 4:09
David Crow15-May-03 4:09 
GeneralRe: Need help with DLL Pin
AnTri15-May-03 4:25
AnTri15-May-03 4:25 
GeneralRe: Need help with DLL Pin
David Crow15-May-03 5:22
David Crow15-May-03 5:22 
GeneralRe: Need help with DLL Pin
AnTri15-May-03 6:09
AnTri15-May-03 6:09 
GeneralRe: Need help with DLL Pin
David Crow15-May-03 6:32
David Crow15-May-03 6:32 
GeneralRe: Need help with DLL Pin
Renjith Ramachandran15-May-03 4:25
Renjith Ramachandran15-May-03 4:25 
GeneralCopying/Moving files Pin
Anonymous15-May-03 3:45
Anonymous15-May-03 3:45 
GeneralRe: Copying/Moving files Pin
Bernhard15-May-03 3:52
Bernhard15-May-03 3:52 
GeneralRe: Copying/Moving files Pin
Johnny ²15-May-03 3:53
Johnny ²15-May-03 3:53 
GeneralRe: Copying/Moving files Pin
AnkushChopra16-May-03 1:56
AnkushChopra16-May-03 1:56 
GeneralActiveX to create OfficeXp like menu Pin
Onkie15-May-03 2:13
Onkie15-May-03 2:13 
GeneralDisable Exit & ask about 'Save File' Pin
LittleYellowBird15-May-03 1:09
LittleYellowBird15-May-03 1:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.