11namespace alpaka::internal
21 template<
typename T,
typename T_ValueMask>
22 struct SmartMaskValueRef
25 using ValueMaskType = T_ValueMask;
27 constexpr SmartMaskValueRef(ValueMaskType& ref) noexcept : valueRef(ref)
32 constexpr operator bool() const noexcept
34 if constexpr(std::is_same_v<ValueMaskType, bool>)
40 return valueRef != ValueMaskType{0};
45 constexpr ValueMaskType value() const noexcept
51 constexpr bool operator!() const noexcept
53 return !
static_cast<bool>(*this);
56 constexpr ValueMaskType operator~() const noexcept
58 if constexpr(std::is_same_v<ValueMaskType, bool>)
65 constexpr ValueMaskType operator|(SmartMaskValueRef
const& rhs)
const noexcept
67 return valueRef | rhs.valueRef;
70 constexpr ValueMaskType operator&(SmartMaskValueRef
const& rhs)
const noexcept
72 return valueRef & rhs.valueRef;
75 constexpr ValueMaskType operator^(SmartMaskValueRef
const& rhs)
const noexcept
77 if constexpr(std::is_same_v<ValueMaskType, bool>)
78 return static_cast<bool>(*
this) !=
static_cast<bool>(rhs);
80 return valueRef ^ rhs.valueRef;
84 constexpr bool operator==(SmartMaskValueRef
const& rhs)
const noexcept
86 return static_cast<bool>(*this) ==
static_cast<bool>(rhs);
89 constexpr bool operator!=(SmartMaskValueRef
const& rhs)
const noexcept
91 return !(*
this == rhs);
94#define SIMD_MASK_REF_ASSIGN_OP(OP, BOOL_FALLBACK) \
95 constexpr SmartMaskValueRef& operator OP(bool b) noexcept \
97 return (*this OP internal::valueMaskCast<ValueMaskType>(b)); \
100 constexpr SmartMaskValueRef& operator OP(ValueMaskType v) noexcept \
102 if constexpr(std::is_same_v<ValueMaskType, bool>) \
104 valueRef = valueRef BOOL_FALLBACK static_cast<bool>(v); \
119#undef SIMD_MASK_REF_ASSIGN_OP
122 ValueMaskType& valueRef;
#define SIMD_MASK_REF_ASSIGN_OP(OP, BOOL_FALLBACK)