Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
maps and constructors
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Erik Wikström, post: 3405118"] Yes, if you use two maps you have to store the key twice, and when retrieving items you have to do the lookup twice too. If you always handle both A and B together there is not reason to keep them in separate maps. Consider also the implications on exception-safety, if you have two maps and want to insert a new pair of A and B and you successfully insert the A into its map but an exception is thrown when inserting B you must remove the A from its map. Yes, at the very least you need the extra memory that is used to store the pointers in addition to the space for the pair. Of course you might be able to save memory using the pointer if multiple entries in the map refer to the same pair of A and B. Depends on how you plan to use C, perhaps you should offer both? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
maps and constructors
Top