Re: Chaining opIndex

2016-05-10 Thread deed via Digitalmars-d-learn
On Monday, 9 May 2016 at 22:33:37 UTC, John Colvin wrote: There are lots of ways to approach this. Here's one possibility: auto cars(Bar bar) { static struct Res { Bar bar; Car opIndex(size_t i) { return /* e.g. getCar(bar, i); */ } } r

Re: Chaining opIndex

2016-05-09 Thread John Colvin via Digitalmars-d-learn
On Monday, 9 May 2016 at 20:14:25 UTC, deed wrote: struct Foo { Bars bars; ... } struct Foos { Foo[] arr; Foo opIndex (size_t idx) { return arr[idx]; } ... } struct Bar { // No Car[] cars; ... } struct Bars { Bar[] arr; Bar opIndex (size_t idx) { return arr[

Chaining opIndex

2016-05-09 Thread deed via Digitalmars-d-learn
struct Foo { Bars bars; ... } struct Foos { Foo[] arr; Foo opIndex (size_t idx) { return arr[idx]; } ... } struct Bar { // No Car[] cars; ... } struct Bars { Bar[] arr; Bar opIndex (size_t idx) { return arr[idx]; } ... } struct Car { ... } Foos foos