std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
来自 cppreference.cn
template< class... OtherIndexTypes > constexpr reference operator[]( OtherIndexTypes... indices ) const; |
(1) | (since C++23) |
template< class OtherIndexType > constexpr reference operator[] |
(2) | (since C++23) |
template< class OtherIndexType > constexpr reference operator[] |
(3) | (since C++23) |
返回到 mdspan 的第 indicesth 元素的引用。
1) 等价于 return acc_.access(ptr_, map_(static_cast<index_type>(std::move(indices))...));。
此重载仅在以下情况参与重载决议:
- (std::is_convertible_v<OtherIndexTypes, index_type> && ...) 为 true 时,
- (std::is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...) 为 true 时,且
- sizeof...(OtherIndexTypes) == rank() 为 true 时。
令
I
为 extents_type::
index-cast
(std::move(indices))。则如果 I
不是 extents() 中的多维索引,即 map_(I) < map_.required_span_size() 为 false 时,行为未定义。2,3) 令
P
为参数包,使得 std::is_same_v<make_index_sequence<rank()>, index_sequence<P...>> 为 true,则运算符等价于 return operator[](extents_type::index-cast
(std::as_const(indices[P]))...);。 此重载仅在以下情况参与重载决议:
- std::is_convertible_v<const OtherIndexType&, index_type> 为 true 时,且
- std::is_nothrow_constructible_v<index_type, const OtherIndexType&> 为 true 时。
内容 |
[编辑] 参数
indices | - | 要访问的元素的索引 |
[编辑] 返回值
元素的引用。
[编辑] 示例
本节尚不完整 原因:无示例 |
[编辑] 缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。
DR | 应用于 | 发布时的行为 | 正确的行为 |
---|---|---|---|
LWG 3974 | C++23 | 重载 (2,3) 未应用 extents_type:: index-cast |
应用 |
[编辑] 参见
本节尚不完整 |