Unexpected Results when Adding an Element to a Unique Key Collection

Effect

You are adding an element into a unique key collection, such as a key set or a map, and you are sure that the collection does not yet contain an element with the same key. Nevertheless, you get unexpected results: IKeyAlreadyExistsException, or the element is not added and the cursor is positioned to a different element.

Reason

This problem has the same cause as the problem described for Compiler Warning of an Error in istdops.h. However, you did not get the warning message described above, because you compiled with a lower warning level.

Solution

Verify that the global key function correctly returns a key const& instead of key.



Introduction to the Collection Classes
Overall Implementation Structure
Element Functions and Key-Type Functions


Implementing Element- and Key-Type Functionality
Defining Member Functions of the Element Object Type
Defining Separate Global Functions
Using or Defining an Element Operation Class
Memory Management with Element Operation Classes
Possible Implementation Paths
Choosing One of the Provided Implementation Variants
Instantiating the Collection Classes
Compiler Warning of an Error in istdops.h