digitalmars.D.learn - opDollar any
- Joseph (3/3) Sep 29 2017 Trying to do multi-dimension array but op-dollar doesn't seem to
- =?UTF-8?Q?Ali_=c3=87ehreli?= (20/27) Sep 29 2017 It's called by multi-dimensional opIndex (or opSlice and perhaps
Trying to do multi-dimension array but op-dollar doesn't seem to support arbitrary dimensions property int opDollar(size_t dim : k)() { return dims[k]; }
Sep 29 2017
On 09/29/2017 11:34 AM, Joseph wrote:Trying to do multi-dimension array but op-dollar doesn't seem to support arbitrary dimensions property int opDollar(size_t dim : k)() { return dims[k]; }It's called by multi-dimensional opIndex (or opSlice and perhaps others?; can be very complicated :) ). import std.stdio; struct S { property size_t opDollar(size_t dim)() { writefln("Called for dimension %s", dim); return dim; } auto opIndex(A...)(A args) { return 42; } } void main() { auto s = S(); s[$, $]; } Called for dimension 0 Called for dimension 1 Ali
Sep 29 2017