[Issue 14935] New: [Operator Overloading] Wrong description on overloading a[]
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Aug 19 05:41:43 PDT 2015
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 at puremagic.com
Reporter: r.97all at 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:".
--
More information about the Digitalmars-d-bugs
mailing list