My set:
std::set<Object> objects;
I want find a object and return it as a reference, also inserting it if it doesn't exist:
const Object& get(params...){
Object obj(params...);
std::set<Object>::const_iterator i = objects.find(obj);
if(i != objects.end())
return *i;
objects.insert(obj);
return * objects.find(obj);
}
This can result in a segmentation fault or this will work always?