You should use std::unordered_map
and its emplace
member function, if you wish to avoid the copy.
Don't store pointers, in general: you may slightly speed up some of your code, but if that was even a bottleneck, the trade-off is more complicated code and the increased risk of bugs. Plus lots of dereferences you don't need.
But feel free to profile all three options if you reckon you need to.