std::experimental::simd_mask<T,Abi>:: operator[]
From cppreference.net
<
cpp
|
experimental
|
simd
|
simd mask
C++
Experimental
| Technical Specification | ||||
| Filesystem library (filesystem TS) | ||||
| Library fundamentals (library fundamentals TS) | ||||
| Library fundamentals 2 (library fundamentals TS v2) | ||||
| Library fundamentals 3 (library fundamentals TS v3) | ||||
| Extensions for parallelism (parallelism TS) | ||||
| Extensions for parallelism 2 (parallelism TS v2) | ||||
| Extensions for concurrency (concurrency TS) | ||||
| Extensions for concurrency 2 (concurrency TS v2) | ||||
| Concepts (concepts TS) | ||||
| Ranges (ranges TS) | ||||
| Reflection (reflection TS) | ||||
| Mathematical special functions (special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
Extensions for parallelism v2
| Parallel exceptions | ||||
| Additional execution policies | ||||
| Algorithms | ||||
| Task blocks | ||||
| Data-parallel vectors | ||||
SIMD library
std::experimental::simd_mask
| Member functions | ||||||||||||
|
||||||||||||
| Non-member functions | ||||||||||||
|
reference operator
[
]
(
size_t i
)
;
|
(1) | (并行技术规范 v2) |
|
bool
operator
[
]
(
size_t i
)
const
;
|
(2) | (并行技术规范 v2) |
下标运算符允许读取和写入
simd_mask
的单个元素。
1)
返回对第 i 个元素的引用代理。此代理类型不应被捕获为左值。
simd_mask::reference
的左值只能转换为
value_type
。
simd_mask::reference
的右值重载了赋值运算符、所有复合赋值运算符以及
swap
操作。
2)
返回第 i 个元素的纯右值。与包含
value_type
类型对象的容器不同,
simd_mask
不是独立对象的容器,因此无法返回左值引用。
参数
| i | - |
元素索引。必须小于
size()
|
示例
运行此代码
#include <cstddef> #include <experimental/simd> #include <iostream> namespace stdx = std::experimental; int main() { stdx::native_simd_mask<int> a{true}; a[1] = 0; for (std::size_t i = 0; i != a.size(); ++i) std::cout << a[i] << ' '; std::cout << '\n'; }
可能的输出:
1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1