www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20617] New: There is no support for copying hashmaps in

https://issues.dlang.org/show_bug.cgi?id=20617

          Issue ID: 20617
           Summary: There is no support for copying hashmaps in Druntime /
                    Phobos
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
void main()
{
    int[int] map1 = [1:1, 2:2, 3:3];
    int[int] map2;
    map2.copy(map1);  // ?
}
-----

I am not asking for special syntax. Stuff like 'map2 = map1[]` would look cool,
but it's outside the scope here.

There should be `copy` functionality implemented somewhere in Druntime /
Phobos, it's not ideal that we have to write this code manually such as:

-----
map1.byKeyValue.each!(pair => map2[pair.key] = pair.value);
-----

--
Feb 26