[Solved] The right way to copy map elements


Considering that your map values are maps themselves, copying those inner maps will be quite expensive. It’s probably slightly cheaper to use pointers to the inner maps than to use iterator, but both are significantly cheaper than copying the inner maps.

However, whether you use pointers or iterators, make sure that they’re not invalidated. The referenced inner maps must stay alive.

11

solved The right way to copy map elements