4 ms·
There's a better solution, to your problem: pass an "index object" as the argument to operator[]. So `T& operator[](index_t)`, where `index_t` could just be a
by xiii1408 8y ago
There's a better solution, to your problem: pass an "index object" as the argument to operator[].
So `T& operator[](index_t)`, where `index_t` could just be a tuple.
a[{1, 2}] = 12;
This has virtually the same syntax, will be compiled in the same way by any modern compiler, and lets you create special index types that have invariants (suppose you want i0 < i1).
- beojan 8y agoThat's not a "better solution", it's a workaround.
- kitd 8y agoI disagree. The tuple is an index into an array. The multiplicity of the tuple indicates (literally, in fact) the multiple dimensions of the array. Ie to the coder, it is the index that takes on the multi-dimensionality, not the array.
- deleted 8y ago[deleted]