Bug 15823 – opIndex doesn't work for const std.variant.Variant

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-23T13:14:00Z
Last change time
2016-03-24T18:57:45Z
Assigned to
nobody
Creator
maximzms

Comments

Comment #0 by maximzms — 2016-03-23T13:14:37Z
Test: ---------- import std.variant; void main() { const v = Variant([1, 2, 3]); auto f = v[1]; // <--- ERROR } ---------- Output: ---------- test.d(6): Error: template std.variant.VariantN!32LU.VariantN.opIndex cannot deduce function from argument types !()(int) const, candidates are: /usr/include/dmd/phobos/std/variant.d(1082): std.variant.VariantN!32LU.VariantN.opIndex(K)(K i) ----------
Comment #1 by maximzms — 2016-03-23T13:40:33Z
Comment #2 by github-bugzilla — 2016-03-24T18:57:45Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/918b58ec37d97fcacbe69b7c4070a0fffed27609 Fix Issue 15823 - Allow opIndex for const Variant https://github.com/D-Programming-Language/phobos/commit/00c5518e7ed0acaa1042b60a18308c28102faead Merge pull request #4112 from MaksimZh/fix-15823 Fix Issue 15823 - allow opIndex for const std.variant.Variant