So, I decided I want to use mdspan
's rather than a span + element access function. But - one obvious thing one would want to do with an (md)span is iterate its elements. This works for spans:
std::vector vec = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
auto sp = std::span(vec.data(), 12);
for (auto x : sp) {
std::cout << x << ' ';
}
std::cout << '\n';
... but not for mdspan
's (using the Kokkos implementation):
std::vector vec = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
auto ms = std::experimental::mdspan(vec.data(), 12);
for (auto x : ms) {
std::cout << x << ' ';
}
std::cout << '\n';
Trying the above in GodBolt (with GCC trunk), I get:
<source>:10:19: error: 'begin' was not declared in this scope
10 | for (auto x : ms) {
| ^~
so, it seems mdspans are not ranges - even if they're one-dimensional (and I was even hoping to iterate 2D or 3D spans...) what gives?