std::experi...:operator[](3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::experi...:operator[](3) πŸ’…

okay bestie, welcome to the C++ Standard Libary page for std::experi...:operator[](3) β€” yes, β€œLibary” is literally how the manual name is spelled, and we are respecting it, no cap πŸ’€βœ¨


🌸 NAME 🌸

std::experimental::simd_mask::operator[] - std::experimental::simd_mask::operator[]


✨ Synopsis ✨

reference operator[]( size_t i );  (1) (parallelism TS v2)
bool operator[]( size_t i ) const; (2) (parallelism TS v2)

The subscript operators let you read and write single elements of a simd_mask. Iconic behavior, honestly 🫢

  1. Returns a reference proxy to the i-th element. This proxy type should not be captured into an lvalue. Lvalues of simd_mask::reference can only convert to value_type. Rvalues of simd_mask::reference overload assignment and all compound assignment operators as well as swap.
  2. Returns a prvalue of the i-th element. In contrast to containers, which contain objects of type value_type, a simd_mask is not a container of individual objects and therefore cannot return an lvalue-reference. That’s just the vibe check it’s giving 😭

πŸŽ€ Parameters πŸŽ€

  • i β€” the element index. Required to be less than size().

πŸ¦‹ Example πŸ¦‹

// Run this code

#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';
}

⭐ Possible output ⭐

1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1

made with πŸ’– by the C++ standard library girlies β€” source: http://cppreference.com, version/date: 2024.06.10, page: std::experi...:operator[](3) πŸ«ΆπŸ’…

πŸ“¦ where this page comes from