最終更新日時:
が更新

履歴 編集

function
<simd>

std::simd::basic_vec::operator+=(C++26)

friend constexpr basic_vec& operator+=(basic_vec& lhs, const basic_vec& rhs) noexcept;

概要

2つのbasic_vecオブジェクトを要素ごとに加算し、その結果を左辺に代入する。

テンプレートパラメータ制約

value_type型の値a, bに対して、式a + bが有効であること。

効果

lhsrhsに対して、加算を要素ごとの演算として適用する。

戻り値

lhs

例外

投げない

#include <simd>
#include <print>

namespace simd = std::simd;

int main()
{
  simd::vec<int, 4> a = [](int i) { return i + 1; };  // {1, 2, 3, 4}
  simd::vec<int, 4> b = 10;                           // {10, 10, 10, 10}

  a += b;

  for (int i = 0; i < a.size(); ++i) {
    std::print("{} ", a[i]);
  }
  std::println("");
}

出力

11 12 13 14 

バージョン

言語

  • C++26

処理系

関連項目

参照