29 #ifndef VC_COMMON_IIF_H_
30 #define VC_COMMON_IIF_H_
32 #include <Vc/type_traits>
35 namespace Vc_VERSIONED_NAMESPACE
40 template<
typename T>
struct assert_for_iif
43 static_assert(Vc::is_simd_vector<T>::value,
"Incorrect use of Vc::iif. If you use a mask as first parameter, the second and third parameters must be of vector type.");
70 template<
typename Mask,
typename T> Vc_ALWAYS_INLINE
71 typename std::enable_if<Vc::is_simd_mask<Mask>::value,
typename assert_for_iif<T>::type>::type
72 iif(
const Mask &condition,
const T &trueValue,
const T &falseValue)
75 Vc::where(condition) | result = trueValue;
110 template<
typename T> constexpr T
iif (
bool condition,
const T &trueValue,
const T &falseValue)
112 return condition ? trueValue : falseValue;
117 #endif // VC_COMMON_IIF_H_
The main SIMD mask class.
constexpr T iif(bool condition, const T &trueValue, const T &falseValue)
Overload of the above for boolean conditions.
constexpr WhereImpl::WhereMask< M > where(const M &mask)
Conditional assignment.