28 #ifndef VC_COMMON_MASK_H_
29 #define VC_COMMON_MASK_H_
33 namespace Vc_VERSIONED_NAMESPACE
41 template <
typename T,
typename Abi = VectorAbi::Best<T>>
class Mask
57 static constexpr
size_t size() {
return VectorTraits<T, Abi>::size(); }
60 static constexpr
size_t Size = VectorTraits<T, Abi>::size();
66 static constexpr
size_t MemoryAlignment = VectorTraits<T, Abi>::maskMemoryAlignment();
93 using VectorType =
typename VectorTraits<T, Abi>::VectorType;
97 using vector_type = VectorType;
139 Vc_INTRINSIC
explicit Mask(VectorSpecialInitializerZero);
143 Vc_INTRINSIC
explicit Mask(VectorSpecialInitializerOne);
155 Vc_INTRINSIC
explicit Mask(
bool b);
163 template <
typename U>
164 Vc_INTRINSIC
Mask(U &&otherMask,
165 Common::enable_if_mask_converts_implicitly<Mask, T, U> = nullarg);
176 template <
typename U>
178 "use simd_cast instead of explicit type casting to convert between mask types")
180 explicit
Mask(U &&otherMask, Common::enable_if_mask_converts_explicitly<T, U> =
181 nullarg) Vc_INTRINSIC_R;
198 Vc_ALWAYS_INLINE
explicit Mask(
const bool *mem);
207 template <
typename Flags> Vc_ALWAYS_INLINE
explicit Mask(
const bool *mem, Flags flags);
215 Vc_ALWAYS_INLINE
void load(
const bool *mem);
224 template <
typename Flags> Vc_ALWAYS_INLINE
void load(
const bool *mem, Flags flags);
232 Vc_ALWAYS_INLINE
void store(
bool *mem)
const;
240 template <
typename Flags> Vc_ALWAYS_INLINE
void store(
bool *mem, Flags flags)
const;
317 Vc_ALWAYS_INLINE
bool isMix()
const;
324 Vc_ALWAYS_INLINE
bool data()
const;
325 Vc_ALWAYS_INLINE
bool dataI()
const;
326 Vc_ALWAYS_INLINE
bool dataD()
const;
382 Vc_FREE_STORE_OPERATORS_ALIGNED(
alignof(
Mask));
401 constexpr
bool all_of(
bool b) {
return b; }
410 constexpr
bool any_of(
bool b) {
return b; }
429 constexpr
bool some_of(
bool) {
return false; }
The main SIMD mask class.
Mask(VectorSpecialInitializerZero)
Zero-initialize the new mask object (false).
void store(bool *mem) const
Store the values of the mask to an array of bool.
Mask operator!() const
Returns a mask with inverted components.
Mask & operator&=(const Mask &mask)
Modifies the mask using an AND operation with mask.
int count() const
Returns how many components of the mask are true.
void store(bool *mem, Flags flags) const
Overload of the above with a load/store flag argument.
static constexpr size_t size()
Returns the number of boolean components ( ) in a mask of this type.
static Mask generate(G &&gen)
Generate a mask object from booleans returned from the function gen.
Mask operator&&(const Mask &mask) const
Returns the component-wise application of a logical AND to mask.
static Mask Zero()
Creates a new mask object initialized to zero/false.
typename VectorTraits< T, Abi >::VectorEntryType VectorEntryType
The VectorEntryType, in contrast to EntryType, reveals information about the SIMD implementation.
bool isMix() const
Returns !isFull() && !isEmpty().
void load(const bool *mem, Flags flags)
Overload of the above with a load/store flag argument.
Mask operator||(const Mask &mask) const
Returns the component-wise application of a logical OR to mask.
bool isNotEmpty() const
Returns a logical OR of all components.
EntryType operator[](size_t index) const
Read-only access to mask entries.
Mask operator|(const Mask &mask) const
Returns the component-wise application of a binary OR to mask.
Mask(const bool *mem)
Load constructor from an array of bool.
void load(const bool *mem)
Load the components of the mask from an array of bool.
Mask(U &&otherMask, Common::enable_if_mask_converts_implicitly< Mask, T, U >=nullarg)
Implicit conversion from a compatible (equal on every platform) mask object.
typename VectorTraits< T, Abi >::EntryReference EntryReference
The reference wrapper type used for accessing individual mask components.
bool operator==(const Mask &mask) const
Returns whether the two masks are equal in all components.
EntryReference value_reference
The reference wrapper type used for accessing individual mask components.
Mask operator^(const Mask &mask) const
Returns the component-wise application of a binary XOR to mask.
Mask operator&(const Mask &mask) const
Returns the component-wise application of a binary AND to mask.
int toInt() const
Convert the boolean components of the mask into bits of an integer.
static Mask One()
Creates a mask object initialized to one/true.
Mask(VectorSpecialInitializerOne)
Initialize the new mask object to one (true).
Mask & operator|=(const Mask &mask)
Modifies the mask using an OR operation with mask.
Abi abi
The ABI tag type of the current template instantiation.
bool operator!=(const Mask &mask) const
Returns whether the two masks are different in at least one component.
bool isEmpty() const
Returns true if components are false, false otherwise.
int firstOne() const
Returns the index of the first one in the mask.
bool isFull() const
Returns a logical AND of all components.
Mask shifted(int amount) const
Returns a mask with components shifted by amount places.
EntryReference operator[](size_t index)
Lvalue-reference-like access to mask entries.
Mask & operator^=(const Mask &mask)
Modifies the mask using an XOR operation with mask.
Mask()=default
Construct a zero-initialized vector object.
Mask(const bool *mem, Flags flags)
Overload of the above with a load/store flag argument.
EntryType value_type
The EntryType of masks is always bool, independent of T.
Mask(bool b)
Broadcast constructor.
bool EntryType
The EntryType of masks is always bool, independent of T.
constexpr bool all_of(bool b)
Returns b.
constexpr bool none_of(bool b)
Returns !b.
constexpr bool any_of(bool b)
Returns b.
constexpr bool some_of(bool)
Returns false.
constexpr std::size_t MemoryAlignment
Specifies the most conservative memory alignment necessary for aligned loads and stores of Vector typ...