提问人:user122049 提问时间:1/13/2023 最后编辑:einpoklumuser122049 更新时间:3/19/2023 访问量:97
存储可在 operator[] 中提供的多维索引的对象
Object that stores multidimensional index that can be supplied in operator[]
问:
由于 C++23 支持多维下标运算符(例如。 并且,是否本机支持将多维索引存储为对象并多次使用?a[1, 2, 3]
mdspan
一个例子可能是
// not storing as object {int a; double b;} due to layout considerations
// maybe we want contiguous accessing a/b individually to be fast but there are
// slow operations using both
std::array<std::array<std::array<int, L>, M>, N> a;
std::array<std::array<std::array<double,L>, M>, N> b;
// Index is conjured up
Index idx{3, 5, 2};
doSomething(a[idx], b[idx]);
我们能从mdspan库中得到什么来实现这一点吗?我觉得在进行上述操作时,这实际上是方便的,但似乎我们需要自己实现。
答: 暂无答案
评论
std::mdspan
的运算符[]
可以采用或,但当然不是所有的多维数组类型都支持这一点。std::span
std::array