According to the SGI doc in associative containers : "Since the elements are stored according to their keys, it is important that the key associated with each element is immutable." I sometimes use the pointer as a key to std :: map, because although the specified object may be mutable, the pointer itself is constant.
QPointer is technically an object that mimics a pointer, and Qt doc says we can use QPointers just like pointers. Since the QPointer object itself can change at run time, can it still be used as the key to the std :: map container?
Edit 1: I cannot use QMap, I have to stick to std :: map.
Editing 2: The code compiles when I use QPointer. The question is whether to expect unpleasant surprises at runtime.
source share