friend constexpr basic_vec& operator-=(basic_vec& lhs, const basic_vec& rhs) noexcept;
概要
2つのbasic_vecオブジェクトを要素ごとに減算し、その結果を左辺に代入する。
テンプレートパラメータ制約
value_type型の値a, bに対して、式a - bが有効であること。
効果
lhsとrhsに対して、減算を要素ごとの演算として適用する。
戻り値
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("");
}
出力
-9 -8 -7 -6
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ❌
- Visual C++: 2026 Update 2 ❌