digitalmars.D.bugs - [Issue 14935] New: [Operator Overloading] Wrong description on
- via Digitalmars-d-bugs (34/34) Aug 19 2015 https://issues.dlang.org/show_bug.cgi?id=14935
https://issues.dlang.org/show_bug.cgi?id=14935 Issue ID: 14935 Summary: [Operator Overloading] Wrong description on overloading a[] Product: D Version: D2 Hardware: All URL: http://dlang.org/ OS: All Status: NEW Severity: enhancement Priority: P3 Component: dlang.org Assignee: nobody puremagic.com Reporter: r.97all gmail.com The code in http://dlang.org/operatoroverloading.html#slice : struct S { int[] impl; int[] opIndex() { return impl[]; } } void test() { auto s = S([1,2,3]); auto t = s[]; // calls s.opIndex() assert(t == [1,2,3]); } doesn't work. When I changed opIndex to opSlice it worked. I suspect that 'opIndex' reads 'opSlice' in the description "To overload a[], simply define opIndex with no parameters:". --
Aug 19 2015