I have QMap
that stores objects and I want to store pointers to these objects for some external processing. Will the pointer to the object remain valid after inserting/deleting some values from map? To illustrate:
QMap <QString, QString> map;
map.insert("one", "one");
map.insert("two", "two");
map.insert("three", "three");
QString *pointer = &map["one"];
qDebug()<<*pointer;
map.insert("aaa", "aaa");
map.insert("bbb", "bbb");
qDebug()<<*pointer;
map.insert("zzz", "zzz");
map.insert("xxx", "xxx");
qDebug()<<*pointer;
Is it guaranteed that pointer
will point to the exact same object after any number of insertions/deletions (considering of course that this object was not removed)
Or should I consider storing pointers instead of objects?