28 #ifndef VC_COMMON_MASKENTRY_H_
29 #define VC_COMMON_MASKENTRY_H_
33 namespace Vc_VERSIONED_NAMESPACE
40 template<
size_t Bytes>
struct MaskBoolStorage;
43 template<>
struct MaskBoolStorage<1> {
typedef std::int8_t type; };
44 template<>
struct MaskBoolStorage<2> {
typedef std::int16_t type; };
45 template<>
struct MaskBoolStorage<4> {
typedef std::int32_t type; };
46 template<>
struct MaskBoolStorage<8> {
typedef std::int64_t type; };
49 template<
size_t Bytes>
class MaskBool
51 typedef typename MaskBoolStorage<Bytes>::type storage_type Vc_MAY_ALIAS;
54 constexpr MaskBool(
bool x) noexcept : data(x ? -1 : 0) {}
55 Vc_ALWAYS_INLINE MaskBool &operator=(
bool x) noexcept { data = x ? -1 : 0;
return *
this; }
56 template <typename T, typename = enable_if<(!std::is_same<T, bool>::value &&
57 std::is_fundamental<T>::value)>>
58 Vc_ALWAYS_INLINE MaskBool &
operator=(T x) noexcept
60 data =
reinterpret_cast<const storage_type &
>(x);
64 Vc_ALWAYS_INLINE MaskBool(
const MaskBool &) noexcept = default;
65 Vc_ALWAYS_INLINE MaskBool &operator=(const MaskBool &) noexcept = default;
67 template <typename T, typename = enable_if<(
std::is_same<T,
bool>::value ||
68 (
std::is_fundamental<T>::value &&
69 sizeof(storage_type) == sizeof(T)))>>
70 constexpr operator T() const noexcept
72 return std::is_same<T, bool>::value ? T((data & 1) != 0)
73 : reinterpret_cast<const MayAlias<T> &>(data);
79 typename std::enable_if<
80 std::is_convertible<A, bool>::value &&std::is_convertible<B, bool>::value,
84 return static_cast<bool>(a) == static_cast<bool>(b);
88 typename std::enable_if<
89 std::is_convertible<A, bool>::value &&std::is_convertible<B, bool>::value,
93 return static_cast<bool>(a) != static_cast<bool>(b);
96 static_assert(
true == MaskBool<4>(
true),
"true == MaskBool<4>(true)");
97 static_assert(
true != MaskBool<4>(
false),
"true != MaskBool<4>(false)");
102 #endif // VC_COMMON_MASKENTRY_H_
result_vector_type< L, R >::mask_type operator!=(L &&lhs, R &&rhs)
Applies != component-wise and concurrently.
result_vector_type< L, R >::mask_type operator==(L &&lhs, R &&rhs)
Applies == component-wise and concurrently.