2 ms·
>"For example, you could create a new object, pass a reference to it to some function that stores it in a hash table, reach the end of your function where the o
by FpUser 5y ago
>"For example, you could create a new object, pass a reference to it to some function that stores it in a hash table, reach the end of your function where the object is automatically deleted, and then have something try to read the object out of the hashtable."
Emplace constructs copy of object in the container. You should be fine.
- dan-robertson 5y agoWhat are you trying to argue here? I’m not claiming that the thing I described is good, only that it is a way to get memory management wrong without calling malloc, so the fact that emplace exists is irrelevant. I think I still don’t understand what your point is because you seem to be arguing against something I’m not claiming.
- FpUser 5y agoIf you are actively looking to shoot yourself in a foot be my guest. But it is your problem, not the one of the language.