C++ 命名需求: LayoutMapping (自 C++23 起)
LayoutMapping 控制多維索引到 std::mdspan 中資料控制代碼的一維偏移量的對映。
目錄 |
[編輯] 要求
型別 M
滿足 LayoutMapping,如果它建模 copyable
和 equality_comparable
,並且以下為 true
- std::is_nothrow_move_constructible_v<M>
- std::is_nothrow_move_assignable_v<M>
- std::is_nothrow_swappable_v<M>
並且,給定以下型別和值,下表中顯示錶達式是有效的並具有指示的語義
[編輯] 圖例
型別 | 定義 |
M
|
佈局對映類 |
值 | 定義 |
m | 型別為(可能帶 const 限定符的)M 的值 |
i, j | (可能帶 const 限定符的)整數包,是 m.extents() 中的多維索引 |
r | typename M::extents_type 的(可能帶 const 限定符的)秩索引 |
d_r | (可能帶 const 限定符的)整數包,其中 sizeof...(d_r) == M::extents_type::rank() 為 true,秩索引 r 處的元素等於 1,所有其他元素等於 0 |
[編輯] 成員型別
名稱 | 型別 | 要求 |
---|---|---|
M::extents_type |
類模板 std::extents 的特化 | |
M::index_type |
typename M::extents_type::index_type | |
M::rank_type |
typename M::extents_type::rank_type | |
M::layout_type |
佈局對映策略 MP ,其中 typename MP::template mapping<E> 是 M 對於某些 extents 型別 E |
LayoutMappingPolicy,其中 M 是 MP 的對映型別 |
[編輯] 成員函式和運算子
表示式 | 返回型別 | 語義 |
---|---|---|
m.extents() | const typename M::extents_type& | 返回關聯多維索引空間的常量引用 |
m(i...) | typename M::index_type |
|
m.required_span_size() | typename M::index_type |
|
m.is_unique() | bool | 僅當對於所有 i 和 j,如果 (i != j || ...) 為 true,則 m(i...) != m(j...) 為 true 時,才返回 true。[注 1] |
m.is_exhaustive() | bool | 僅當對於範圍 [ 0, m.required_span_size()) 中的所有 k,存在一個 i 使得 m(i...) 等於 k 時,才返回 true。[注 2] |
m.is_strided() | bool | 僅當對於 m.extents() 的每個秩索引 r,存在一個整數 s_r 使得,對於所有 i,其中 (i + d_r) 是 m.extents() 中的多維索引,m((i + d_r)...) - m(i...) 等於 s_r 時,才返回 true。[注 3] |
m.stride(r) | typename M::index_type |
|
M::is_always_unique() | bool |
|
M::is_always_exhaustive() | bool |
|
M::is_always_strided() | bool |
|
[編輯] 概念
對於 std::layout_stride::mapping 下使用的約束,定義了以下僅用於說明的概念。
template< class M > concept /*layout-mapping-alike*/ = requires |
(僅作說明*) | |
定義了 LayoutMapping 需求的最小可用性約束。此概念檢查上述謂詞對映特性函式是否存在、是否為常量表達式,以及返回型別是否為 bool。
/*is-extents*/<E> 當且僅當 E
是 std::extents 的特化時,才為 true。
[編輯] 標準庫
以下標準庫型別滿足 LayoutMapping 要求
layout_left 的佈局對映 ( std::layout_left 的公共成員類模板) | |
layout_right 的佈局對映 ( std::layout_right 的公共成員類模板) | |
layout_stride 的佈局對映 ( std::layout_stride 的公共成員類模板) | |
layout_left_padded 的佈局對映 ( std::layout_left_padded<PaddingValue> 的公共成員類模板) | |
layout_right_padded 的佈局對映 ( std::layout_right_padded<PaddingValue> 的公共成員類模板) |