std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
來自 cppreference.com
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 |
已應用 |
[編輯] 參閱
本節不完整 |