std::experimental::simd<T,Abi>::operator[]

来自cppreference.com
< cpp‎ | experimental‎ | simd‎ | simd
 
 
实验性
技术规范
文件系统库 (文件系统 TS)
库基础 (库基础 TS)
库基础 2 (库基础 TS v2)
库基础 3 (库基础 TS v3)
并行扩展 (并行 TS)
并行扩展 2 (并行 TS v2)
并发扩展 (并发 TS)
并发扩展 2 (并发 TS v2)
概念 (概念 TS)
范围 (范围 TS)
反射 (反射 TS)
数学特殊函数 (特殊函数 TR)
实验性非 TS 功能特性
模式匹配
线性代数
std::execution
契约
2D 图形
 
 
 
 
reference operator[]( std::size_t i );
(1) (并行 TS v2)
value_type operator[]( std::size_t i ) const;
(2) (并行 TS v2)

The subscript operators allow reading and writing single elements of a simd.

1) Returns a reference proxy to the i-th element. This proxy type should not be captured into an lvalue. Lvalues of simd::reference can only convert to value_type. Rvalues of simd::reference overload assignment and all compound assignment operators as well as swap.
2) 返回第 i 个元素的纯右值。In contrast to containers, which contain objects of type value_type, a simd is not a container of individual objects and therefore cannot return an lvalue-reference.

[编辑] 参数

i - 元素索引。要求其小于 size()

[编辑] 示例

#include <cstddef>
#include <cstdint>
#include <experimental/simd>
#include <iostream>
namespace stdx = std::experimental;
 
int main()
{
    const stdx::native_simd<std::int64_t> a = 3;
    for (std::size_t i = 0; i != a.size(); ++i)
        std::cout << a[i] << ' ';
    std::cout << '\n';
}

可能的输出:

3 3 3 3 3 3 3 3