C++ / Why Iterators Got It All Wrong
jmh530 via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 7 13:46:22 PDT 2017
On Thursday, 7 September 2017 at 12:28:00 UTC, jmh530 wrote:
> On Thursday, 7 September 2017 at 12:27:19 UTC, jmh530 wrote:
>>
>> auto x = data.sliced(2, 3).universal;
>
> Err, (3, 4) not (2, 3)
All kinds of screwed up. This is what I get for not testing
things before I post them.
unittest {
auto data = iota(12);
auto x = data.sliced(3, 4).universal;
assert(x.strides == [4, 1]);
assert(x[1, 2] == data[1 * 4 + 2 * 1]);
auto y = x.transposed;
assert(y.strides == [1, 4]);
assert(y[1, 2] == data[1 * 1 + 2 * 4]);
}
More information about the Digitalmars-d
mailing list