www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24037] New: assocArray should support immutable values

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

          Issue ID: 24037
           Summary: assocArray should support immutable values
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

```
import std.array;
import std.typecons;

immutable struct S { int a; }

void main() {
    auto array = [tuple!("key", "value")(2, S(1))].assocArray;
}
```

Leads to Error: static assert:  "assocArray: value type must be mutable"

Since `assocArray(keys, values)` can construct an immutable assoc array just
fine, this should also work with `assocArray(range)`.

--
Jul 07 2023