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); */
        }
    }
    return Res(bar);
}

Thanks. Didn't think of function returning struct with opIndex. Having this as opCall in a struct Cars might be a solution.

What other approaches did you have in mind?

Reply via email to