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 if
checking) will both invoke copy
. So.. Is the competition between :
insert
[ ]
(withif
checking)[ ]
(withif
checking and swap)
which one would you prefer?
thanks again