Regarding an unordered_map with the following declaration:
typedef struct
{
unsigned int length;
unsigned type;
std::string data;
} packet;
boost::unordered::unordered_map<int, packet> map;
When I add an object to this map, the unordered_map will clone this object and append it to its container. So my question is it better to have a pointer to the struct instead of adding it as an object?
And if I have a raw pointer as the value in the unordered_map, is there any method I should follow to keep the object alive in the memory and its place not used by other variable even if I get out of the function scope?