I have a map which holds CStringArray as its value. The declaration is something like
std::map<int, CStringArray&> string_list;
The purpose of this map is to store strings which are having same index number.
So, The first time when I am inserting the string, the process is working fine. But when I am inserting the second element for the same key, i.e, updating the CStringArray which is already present against key, the app is getting crashed.
PF below code FYI..
void FillMyMap(const int key, const CString& str) {
string_list::iterator list_itr = my_mapp.find(key); //my_map is a member
if (list_itr != my_mapp.end()) {
(list_itr->second).Add(str); //crash occured
} else {
CStringArray str_arr;
str_arr.Add(str);
my_mapp.Insert(std::pair<int, CStringArray&>(key, str_arr)); //working fine
}
}
The same code worked fine when I replace "CStringArray" with "Vector of CStrings". Can you please explain me why this crash occurred? Thanks in advance.