Bug 17711 – std.array.byPair should be usable with const AA
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-08-01T22:53:39Z
Last change time
2018-01-05T13:30:56Z
Keywords
pull
Assigned to
No Owner
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2017-08-01T22:53:39Z
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)
------