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 的第 indices 个元素的引用。
此重载只有在以下所有值都是 true 时才会参与重载决议:
- (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 起) |
2,3) 设
std::index_sequence<P...>> 是 true 的形参包,等价于 return operator[](extents_type::
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]))...);。 此重载只有在以下所有值都是 true 时才会参与重载决议:
- std::is_convertible_v<const OtherIndexType&, index_type>
- std::is_nothrow_constructible_v<index_type, const OtherIndexType&>
目录 |
[编辑]参数
indices | - | 要访问的元素的索引 |
[编辑]返回值
元素的引用。
[编辑]示例
本节未完成 原因:暂无示例 |
[编辑]缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
---|---|---|---|
LWG 3974 | C++23 | 重载 (2,3) 没有应用 extents_type:: index-cast | 会应用 |
[编辑]参阅
本节未完成 |