15 KiB
[simd.mask.class]
29 Numerics library [numerics]
29.10 Data-parallel types [simd]
29.10.9 Class template basic_mask [simd.mask.class]
29.10.9.1 Class template basic_mask 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; 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, Abi>>size {}; constexpr basic_mask() noexcept = default; // [simd.mask.ctor], basic_mask constructorsconstexpr explicit basic_mask(value_type) noexcept; template<size_t UBytes, class UAbi>constexpr explicit basic_mask(const basic_mask<UBytes, UAbi>&) noexcept; templateconstexpr explicit basic_mask(G&& gen) noexcept; constexpr basic_mask(const bitset<size()>& b) noexcept; constexpr explicit basic_mask(unsigned_integral auto val) noexcept; // [simd.mask.subscr], basic_mask subscript operatorsconstexpr value_type operator const; template<simd-integral I>constexpr resize_t<I::size(), basic_mask> operator[](const I& indices) const; // [simd.mask.unary], basic_mask unary operatorsconstexpr basic_mask operator!() const noexcept; constexpr basic_vec<integer-from, Abi> operator+() const noexcept; constexpr basic_vec<integer-from, Abi> operator-() const noexcept; constexpr basic_vec<integer-from, Abi> operator~() const noexcept; // [simd.mask.conv], basic_mask conversionstemplate<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 long to_ullong() const; // [simd.mask.binary], basic_mask binary operatorsfriend 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 assignmentfriend 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 comparisonsfriend 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 operatorsfriend constexpr basic_mask simd-select-impl( // exposition onlyconst basic_mask&, const basic_mask&, const basic_mask&) noexcept; friend constexpr basic_mask simd-select-impl( // exposition onlyconst basic_mask&, same_as auto, same_as 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]
29.10.9.2 basic_mask constructors [simd.mask.ctor]
constexpr explicit basic_mask(value_type x) 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() istrue.
Effects: Initializes the ith element with x[i] for all i in the range of [0, size()).
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 ith element withgen(integral_constant<simd-size-type, i>()) for all i in the range of [0, size()).
Remarks: gen is invoked exactly once for each i, in increasing order of i.
constexpr basic_mask(const bitset<size()>& b) noexcept;
Effects: Initializes the ith element with b[i] for all i in the range [0, size()).
constexpr explicit basic_mask([unsigned_integral](concepts.arithmetic#concept:unsigned_integral "18.4.7 Arithmetic concepts [concepts.arithmetic]") auto val) noexcept;
Effects: Initializes the first M elements to the corresponding bit values inval, where M is the smaller of size() and the number of bits in the value representation ([basic.types.general]) of the type of val.
IfM is less than size(), the remaining elements are initialized to zero.
29.10.9.3 basic_mask subscript operator [simd.mask.subscr]
constexpr value_type operator[](simd-size-type i) const;
Preconditions: i >= 0 && i < size() is true.
Returns: The value of the ith element.
Throws: Nothing.
template<[simd-integral](simd.expos#concept:simd-integral "29.10.2 Exposition-only types, variables, and concepts [simd.expos]") I> constexpr resize_t<I::size(), basic_mask> operator[](const I& indices) const;
Effects: Equivalent to: return permute(*this, indices);
29.10.9.4 basic_mask unary operators [simd.mask.unary]
constexpr basic_mask operator!() const noexcept; constexpr basic_vec<integer-from<Bytes>, Abi> operator+() const noexcept; constexpr basic_vec<integer-from<Bytes>, Abi> operator-() const noexcept; constexpr basic_vec<integer-from<Bytes>, Abi> operator~() const noexcept;
Let op be the operator.
Returns: A data-parallel object where the ith element is initialized to the results of applying op to operator for all i in the range of [0, size()).
29.10.9.5 basic_mask conversions [simd.mask.conv]
template<class U, class A> constexpr explicit(sizeof(U) != Bytes) operator basic_vec<U, A>() const noexcept;
Constraints: simd-size-v<U, A> == simd-size-v<T, Abi>.
Returns: A data-parallel object where the ith element is initialized tostatic_cast(operator).
constexpr bitset<size()> to_bitset() const noexcept;
Returns: A bitset<size()> object where the ith element is initialized tooperator for all i in the range [0, size()).
constexpr unsigned long long to_ullong() const;
Let N be the width of unsigned long long.
Preconditions:
size() <= N is true, or
for all i in the range [N, size()), operator returns false.
Returns: The integral value corresponding to the bits in *this.
Throws: Nothing.