mardi 22 janvier 2019

Whether to use class instances or std::shared_ptr

I have a map which stores attacks for different ports. Now I am confused as for how to store attack details as the value. Also, there can be multiple attacks for one port.

AttackDetails is a structure containing various details of each attack.

Now I have two approaches for the map:

std::map <int, std::list<AttackDetails>>
std::map <int, std::list<<std::shared_ptr<AttackDetails>>>

There won't be much insertion or deletion but there will be a lot of searchings for port in map. Kindly tell me if there is any major performance issue in either of these or any better solution to it?

Aucun commentaire:

Enregistrer un commentaire