std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>:: operator[]
|
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 第 indices th 个元素的引用。
acc_
.
access
(
ptr_
,
map_
(
static_cast
<
index_type
>
(
std
::
move
(
indices
)
)
...
)
)
;
。
- ( std:: is_convertible_v < OtherIndexTypes, index_type > && ... )
- ( std:: is_nothrow_constructible_v < index_type, OtherIndexTypes > && ... )
- sizeof... ( OtherIndexTypes ) == rank ( )
|
如果
extents_type
::
|
(C++26 前) |
|
如果
extents_type
::
|
(C++26 起) |
P
为形参包,满足
std::
is_same_v
<
std::
make_index_sequence
<
rank
(
)
>
,
std:: index_sequence < P... >> 为 true ,等价于 return operator [ ] ( extents_type ::
index-cast
(
std::
as_const
(
indices
[
P
]
)
)
...
)
;
。
- std:: is_convertible_v < const OtherIndexType & , index_type >
- std:: is_nothrow_constructible_v < index_type, const OtherIndexType & >
目录 |
参数
| indices | - | 要访问的元素的索引 |
返回值
对元素的引用。
示例
|
本节内容不完整
原因:缺少示例 |
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| DR | 适用范围 | 发布时的行为 | 正确行为 |
|---|---|---|---|
| LWG 3974 | C++23 |
重载版本
(2,3)
未应用
extents_type::
index-cast
|
已应用 |
参见
| 本节内容尚不完整 |