I was wondering how long the value refers to inside the Qt container, especially QHash or QMap . By valid, I mean that if you insert or delete other elements, you should still indicate the correct location inside the map / hash.
Let the following code:
QHash<char,int> dict; // or QMap<char,int> dict; dict.insert('a', 1); int& val(dict['a']); dict.insert('b', 2); val = 3; // < will this work or lead to a segfault
Will the value on the last line correctly update the value associated with a to 3 , or it will result in segfault or it will be undefined (so sometimes run segfault at a different time, depending on whether the data structure should have been reorganized internally e.g. resizing a hash table array). Is the behavior the same for QMap and QHash , or does one work and the other not?
source share