std::experi...ator!,~,+,-(3)
π NAME π
okay bestie, welcome to the std::experi...ator!,~,+,-(3) page, straight outta the C++ Standard Libary manual π«Ά. The names on this one are std::experimental::simd::operator!,~,+,- - and std::experimental::simd::operator!,~,+,- β yes, both, and that trailing dash is literally part of the NAME section π.
β¨ Synopsis β¨
mask_type operator!() const noexcept; (1) (parallelism TS v2)
simd operator~() const noexcept; (2) (parallelism TS v2)
simd operator+() const noexcept; (3) (parallelism TS v2)
simd operator-() const noexcept; (4) (parallelism TS v2)
lowkey the whole idea: it applies the given unary operator on each element of the simd π«. Here's the breakdown, no skips:
- Returns a
simd_mask<T, Abi>where the i^th element equals!operator[](i)for alliin the range of[0, size()). π - Returns a
simdwhere each bit is the inverse of the corresponding bit in*this. This overload participates in overload resolution only ifTis an integral type. π§ - Returns a copy of itself. iconic. π
- Returns a
simdwhere the i^th element is initialized to-operator[](i)for alliin the range of[0, size()). π₯
πΈ Example πΈ
// Run this code
#include <cstddef>
#include <experimental/simd>
#include <iostream>
#include <string_view>
namespace stdx = std::experimental;
void println(std::string_view op, const stdx::native_simd_mask<int> x)
{
std::cout << op << ": ";
for (std::size_t i = 0; i < x.size(); ++i)
std::cout << std::boolalpha << x[i] << ' ';
std::cout << '\n';
}
void println(std::string_view op, const stdx::native_simd<int> x)
{
std::cout << op << ": ";
for (std::size_t i = 0; i < x.size(); ++i)
std::cout << x[i] << ' ';
std::cout << '\n';
}
int main()
{
const stdx::native_simd<int> a([](int i) { return i; });
println(" a", a);
println(" !a", !a);
println(" ~a", ~a);
println("~~a", ~~a);
println(" +a", +a);
println(" -a", -a);
println("+-a", +-a);
}
π Possible output π
a: 0 1 2 3
!a: true false false false
~a: -1 -2 -3 -4
~~a: 0 1 2 3
+a: 0 1 2 3
-a: 0 -1 -2 -3
+-a: 0 -1 -2 -3
mwah π this page signs off with source/version http://cppreference.com and the date 2024.06.10 β periodt πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms