How could I create a copy of an unordered_map from an existing one? Could I use assignment operator or I need to iterate it one by one? Also, I am using shared_ptr as the value in the map. Did I need to take extra care because it is shared_ptr?
typedef unordered_map<string, shared_ptr<classA>>MAP1;
MAP1 map1;
map1["abc"] = make_shared<classA>();
MAP2 map2 = map1; ?? //can I use assignment operator??
Thanks.
Yes you can.
Regarding shared_ptr, if you want the copied pointers to point to the same values then no. If you want two separate copy (deep copy), then you need to do the copying yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With