a struct as an multidimensional array index
H. S. Teoh
hsteoh at qfbox.info
Fri Jun 10 14:56:20 UTC 2022
On Fri, Jun 10, 2022 at 08:08:45AM +0000, Chris Katko via Digitalmars-d-learn wrote:
> Is it somehow possible to use a struct as a [multidimensional] array index:
>
> ````D
>
> struct indexedPair
> {
> size_t x, y;
> }
>
> bool isMapPassable[100][100];
> auto p = indexedPair(50, 50);
>
> if(isMapPassable[p]) return true;
>
> ````
>
> Probably not, but I'm curious.
See: https://dlang.org/spec/operatoroverloading.html#array-ops
T
--
It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall
More information about the Digitalmars-d-learn
mailing list