| > In C++ you just do `auto a = b;`. Sure, but does it do what you want? :) If that map contains pointers or other types with "interesting" assignment semantics, then your idea of a deep copy and that author of that type's idea may not be the same. Cloning is a surprisingly hard problem. The two languages you compare to don't have GCs and prefer value semantics. But in most GC languages, everything is by reference and "copying the bits" isn't as meaningful of an operation. I looked up how to deep clone maps in some other GC languages: https://stackoverflow.com/questions/4157399/how-do-i-copy-a-... Ruby: Top suggestion is to marhsall/unmarshall it. https://stackoverflow.com/questions/5105517/deep-copy-of-a-d... Python: Import a separate "copy" module. May have to implement some custom methods if you use user-defined objects in the map. The module isn't thread-safe. A comment recommends converting to JSON and back. https://stackoverflow.com/questions/28288546/how-to-copy-has... Java: No built in solution. Have to traverse the map yourself and do element-wise copies. |