std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
来自 cppreference.cn
template< class... OtherIndexTypes > constexpr reference operator[]( OtherIndexTypes... indices ) const; |
(1) | (C++23 起) |
template< class OtherIndexType > constexpr reference operator[] |
(2) | (C++23 起) |
template< class OtherIndexType > constexpr reference operator[] |
(3) | (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++ 标准。
缺陷报告 | 应用于 | 发布时的行为 | 正确的行为 |
---|---|---|---|
LWG 3974 | C++23 | 重载 (2,3) 未应用 extents_type:: index-cast |
已应用 |
[编辑] 参阅
本节不完整 |