Closed caaatch22 closed 7 months ago
std::array<int, 12> a; std::iota(a.begin(), a.end(), 0); auto sp = std::mdspan(a.data(), 2, 2, 3); auto p = std::submdspan(sp, 0, 1, std::full_extent); std::cout << "p.rank : " << p.rank() << '\n'; // p.rank : 1 auto d = std::submdspan(sp, 0, 1, 2); std::cout << "d.rank : " << d.rank() << '\n'; // d.rank : 0 std::cout << p[0] << '\n'; // std::cout << d[0] << '\n'; // this won't compile
Is this a bug or intention? since we may need a mdspan with only one value by submdspan method or we must write auto d = std::submdspan(sp, 0, 0, tuple{0, 1}) ?
auto d = std::submdspan(sp, 0, 0, tuple{0, 1})
It is by design. When you do auto d = std::submdspan(sp, 0, 1, 2);, d is rank-0 and you access the unique element via d[].
auto d = std::submdspan(sp, 0, 1, 2);
d
d[]
Is this a bug or intention? since we may need a mdspan with only one value by submdspan method or we must write
auto d = std::submdspan(sp, 0, 0, tuple{0, 1})
?