Bug 9314 – std.algorithm.minCount of const(int)[]

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-13T21:04:00Z
Last change time
2013-10-24T06:36:15Z
Keywords
pull, rejects-valid
Assigned to
monarchdodra
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-01-13T21:04:25Z
Related to Issue 9299 import std.algorithm: minCount; import std.typecons: tuple; void main() { int[] a1 = [2, 3, 1, 4, 1, 1]; assert(minCount(a1) == tuple(1, 3)); const(int)[] a2 = [2, 3, 1, 4, 1, 1]; assert(minCount(a2) == tuple(1, 3)); immutable int[] a3 = [2, 3, 1, 4, 1, 1]; assert(minCount(a3) == tuple(1, 3)); } DMD 2.062alpha gives: ..\dmd2\src\phobos\std\algorithm.d(1541): Error: cannot modify const expression target ..\dmd2\src\phobos\std\algorithm.d(6173): Error: template instance std.algorithm.move!(const(int)) error instantiating temp.d(7): instantiated from here: minCount!("a < b", const(int)[]) temp.d(7): Error: template instance std.algorithm.minCount!("a < b", const(int)[]) error instantiating ..\dmd2\src\phobos\std\algorithm.d(1541): Error: cannot modify immutable expression target ..\dmd2\src\phobos\std\algorithm.d(6173): Error: template instance std.algorithm.move!(immutable(int)) error instantiating temp.d(9): instantiated from here: minCount!("a < b", immutable(int)[]) temp.d(9): Error: template instance std.algorithm.minCount!("a < b", immutable(int)[]) error instantiating
Comment #1 by andrej.mitrovich — 2013-10-24T06:35:28Z
Comment #2 by github-bugzilla — 2013-10-24T06:35:40Z
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/9461ff427ea5b9ad012e2145d43dadcac4b700d8 Merge pull request #1074 from monarchdodra/9314 Issue 9314 - std.algorithm.minCount of const(int)[]