a struct as an multidimensional array index
Ali Çehreli
acehreli at yahoo.com
Fri Jun 10 15:01:40 UTC 2022
On 6/10/22 07:38, Ali Çehreli wrote:
> I played with that toString function but for some reason it prints all
> Ts. (?)
Fixed it by changing one of the lambdas to take by reference:
void toString(scope void delegate(in char[]) sink) const {
import std.algorithm;
sink.formattedWrite!"%-(%-(%s %)\n%)"(
elements[].map!((ref row) => row[].map!(column => column ? 'T' :
'f')));
// ^^^
}
I still don't understand the reason though. The rows would be copied
without ref but should retain their type as bool[3], a static array. (?)
Ali
More information about the Digitalmars-d-learn
mailing list