[Issue 17711] New: std.array.byPair should be usable with const AA

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Aug 1 15:53:39 PDT 2017


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

          Issue ID: 17711
           Summary: std.array.byPair should be usable with const AA
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at quickfur.ath.cx

Code:
------
import std.array;
const(int[string]) aa = [ "abc": 123 ];
auto r = aa.byPair;
------

This code ought to compile, but doesn't, because const(int[string]) does not
match the function declaration `auto byPair(K,V)(Value[Key] aa)`.

However, the implementation actually supports iterating over const AA's just
fine. We just need to declare the function differently so that it will match a
const AA type:

------
auto byPair(AA : V[K], V, K)(AA aa)
------

--


More information about the Digitalmars-d-bugs mailing list