29 Numerics library [numerics]

29.10 Data-parallel types [simd]

29.10.9 Class template basic_mask [simd.mask.class]


29.10.9.1 Overview [simd.mask.overview]

29.10.9.2 Constructors [simd.mask.ctor]

29.10.9.3 Subscript operator [simd.mask.subscr]

29.10.9.4 Unary operators [simd.mask.unary]

29.10.9.5 Conversions [simd.mask.conv]


29.10.9.1 Overview [simd.mask.overview]

namespace std::simd { template<size_t Bytes, class Abi> class basic_mask { public: using value_type = bool; using abi_type = Abi; using iterator = simd-iterator<basic_mask>; using const_iterator = simd-iterator<const basic_mask>; constexpr iterator begin() noexcept { return {*this, 0}; } constexpr const_iterator begin() const noexcept { return {*this, 0}; } constexpr const_iterator cbegin() const noexcept { return {*this, 0}; } constexpr default_sentinel_t end() const noexcept { return {}; } constexpr default_sentinel_t cend() const noexcept { return {}; } static constexpr integral_constant<simd-size-type, simd-size-v<integer-from<Bytes>, Abi>> size {}; constexpr basic_mask() noexcept = default; / [simd.mask.ctor], basic_mask constructors constexpr explicit basic_mask(same_as<value_type> auto) noexcept; template<size_t UBytes, class UAbi> constexpr explicit basic_mask(const basic_mask<UBytes, UAbi>&) noexcept; template<class G> constexpr explicit basic_mask(G&& gen); template<same_as<bitset<size()> T> constexpr basic_mask(const T& b) noexcept; template<unsigned_integral T> requires (!same_as<T, value_type>) constexpr explicit basic_mask(T val) noexcept; / [simd.mask.subscr], basic_mask subscript operators constexpr value_type operator[](simd-size-type) const; template<simd-integral I> constexpr resize_t<I::size(), basic_mask> operator[](const I& indices) const; / [simd.mask.unary], basic_mask unary operators constexpr basic_mask operator!() const noexcept; constexpr see below operator+() const noexcept; constexpr see below operator-() const noexcept; constexpr see below operator~() const noexcept; / [simd.mask.conv], basic_mask conversions template<class U, class A> constexpr explicit(sizeof(U) != Bytes) operator basic_vec<U, A>() const noexcept; constexpr bitset<size()> to_bitset() const noexcept; constexpr unsigned long to_ullong() const; / [simd.mask.binary], basic_mask binary operators friend constexpr basic_mask operator&(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator|(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator&(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator|(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator^(const basic_mask&, const basic_mask&) noexcept; / [simd.mask.cassign], basic_mask compound assignment friend constexpr basic_mask& operator&=(basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask& operator|=(basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask& operator^=(basic_mask&, const basic_mask&) noexcept; / [simd.mask.comparison], basic_mask comparisons friend constexpr basic_mask operator=(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator!=(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator>=(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator<=(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator>(const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask operator<(const basic_mask&, const basic_mask&) noexcept; / [simd.mask.cond], basic_mask exposition only conditional operators friend constexpr basic_mask simd-select-impl( / exposition only const basic_mask&, const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask simd-select-impl( / exposition only const basic_mask&, same_as<bool> auto, same_as<bool> auto) noexcept; template<class T0, class T1> friend constexpr vec<see below, size()> simd-select-impl(const basic_mask&, const T0&, const T1&) noexcept; / exposition only }; }
Every specialization of basic_mask is a complete type.
The specialization of basic_mask<Bytes, Abi> is:
  • disabled, if there is no vectorizable type T such that Bytes is equal to sizeof(T),
  • otherwise, enabled, if there exists a vectorizable type T and a value N in the range [1, 64] such that Bytes is equal to sizeof(T) and Abi is deduce-abi-t<T, N>,
  • otherwise, it is implementation-defined if such a specialization is enabled.
If basic_mask<Bytes, Abi> is disabled, the specialization has a deleted default constructor, deleted destructor, deleted copy constructor, and deleted copy assignment.
In addition only the value_type and abi_type members are present.
If basic_mask<Bytes, Abi> is enabled, basic_mask<Bytes, Abi> is trivially copyable.
Recommended practice: Implementations should support implicit conversions between specializations of basic_mask and appropriate implementation-defined types.
[Note 1: 
Appropriate types are non-standard vector types which are available in the implementation.
— end note]
constexpr explicit basic_mask(same_as<value_type> auto) noexcept;
Effects: Initializes each element with x.
template<size_t UBytes, class UAbi> constexpr explicit basic_mask(const basic_mask<UBytes, UAbi>& x) noexcept;
Constraints: basic_mask<UBytes, UAbi>​::​size() == size() is true.
Effects: Initializes the
template<class G> constexpr explicit basic_mask(G&& gen);
Constraints: The expression gen(integral_constant<simd-size-type, i>() is well-formed and its type is bool for all i in the range of [0, size()).
Effects: Initializes the
Remarks: gen is invoked exactly once for each i, in increasing order of i.
template<same_as<bitset<size()> T> constexpr basic_mask(const T& b) noexcept;
Effects: Initializes the
template<unsigned_integral T> requires (!same_as<T, value_type>) constexpr explicit basic_mask(T val) noexcept;
Effects: Initializes the first M elements to the corresponding bit values in val, where M is the smaller of size() and the number of bits in the value representation ([basic.types.general]) of the type of val.
If M is less than size(), the remaining elements are initialized to zero.

29.10.9.3 Subscript operator [simd.mask.subscr]

constexpr value_type operator[](simd-size-type i) const;
Throws: Nothing.
template<simd-integral I> constexpr resize_t<I::size(), basic_mask> operator[](const I& indices) const;
Effects: Equivalent to: return permute(*this, indices);
constexpr basic_mask operator!() const noexcept; constexpr see below operator+() const noexcept; constexpr see below operator-() const noexcept; constexpr see below operator~() const noexcept;
Returns: A data-parallel object where the
Remarks: If there exists a vectorizable signed integer type I such that sizeof(I) == Bytes is true, operator+, operator-, and operator return an enabled specialization R of basic_vec such that R​::​value_type denotes integer-from<Bytes> and R​::​size() == size() is true.
Otherwise, these operators are defined as deleted and their return types are unspecified.
template<class U, class A> constexpr explicit(sizeof(U) != Bytes) operator basic_vec<U, A>() const noexcept;
Returns: A data-parallel object where the
constexpr bitset<size()> to_bitset() const noexcept;
Returns: A bitset<size()> object where the
constexpr unsigned long to_ullong() const;
Throws: Nothing.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant