I'm having hard time to understand life time semantics of smart pointers when they are stored inside a global unordered_map.
Consider this global code block,
struct Connection {
// Variables goes here
};
std::unordered_map<std::string_view, std::unique_ptr<Connection>> connections;
Do this connection object stored in unique_ptr get destruct when you just perform a one time lookup on map then access it?
If yes, how could I make it available for multiple times not just 1 time?
Aucun commentaire:
Enregistrer un commentaire