I\'ve tried playing with clang\'s extended vectors. The ternary operator is supposed to work, but it is not working for me. Example:
int main()
{
using int4 =
In the end I went with this:
#if defined(__clang__)
template
constexpr inline std::enable_if_t<
!std::is_arithmetic{},
V
>
select(V const a, V const b, U const c) noexcept
{
return V((c & U(a)) | (~c & U(b)));
}
#else
template
constexpr inline std::enable_if_t<
!std::is_arithmetic{},
V
>
select(V const a, V const b, U const c) noexcept
{
return c ? a : b;
}
#endif
The same could have been accomplished in other ways, using the indices trick, for example, but it might not optimize very well (I didn't want any conditionals in there).