opDollar any
Ali Çehreli
acehreli at yahoo.com
Fri Sep 29 18:53:36 UTC 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
More information about the Digitalmars-d-learn
mailing list