C++ named requirements: LayoutMapping (since 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
对于某个维度类型
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 || ... ) 为 true 的 i 和 j , 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 + d_r ) 是 m. extents ( ) 中多维索引的 i , 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 |
|
- ↑ 即使条件满足,映射也可能返回 <span class="t-c
概念
对于在 std::layout_stride::mapping 下使用的约束条件,定义了以下仅用于说明的概念。
|
template
<
class
M
>
concept
/*布局映射类似体*/
=
requires
|
( 仅用于说明* ) | |
定义 LayoutMapping 要求的最小可用性约束。此概念检查上述谓词映射特征函数是否存在、是否为常量表达式,并具有 bool 返回类型。
/*is-extents*/
<
E
>
为
true
当且仅当
E
是
std::extents
的特化。
标准库
以下标准库类型满足 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>
的公开成员类模板)
|