having:
std::map<const std::string,A > cache;
how would you insert into this container(duplicate attempt is possible):
cache.insert(std::make_pair(id,ps));
cache.insert(std::pair<std::string,A>(id,ps));
if(cache.find(id) == cache.end()){
cache[id] = ps;
}
and why??(in terms of time and memory)
do you have a better solution?
Update: I am not using C++11
Update-2: OK, so far we realised that:
make_pair and pair<> are analogous.
insert and [ ](with or without ifchecking) will both invoke copy. So.. Is the competition between :
insert[ ](withifchecking)[ ](withifchecking and swap)
which one would you prefer?
thanks again