@@ -2258,7 +2258,7 @@ namespace xsimd
22582258 using register_type = typename batch_bool<T, A>::register_type;
22592259 register_type r = 0 ;
22602260 unsigned shift = 0 ;
2261- (void )std::initializer_list<register_type> { (r |= register_type (values ? 1 : 0 ) << (shift++))... } ;
2261+ ((r |= register_type (values ? 1 : 0 ) << (shift++)), ...) ;
22622262 return r;
22632263 }
22642264
@@ -2656,21 +2656,19 @@ namespace xsimd
26562656
26572657 namespace detail
26582658 {
2659- template <class T , class A , T... Idx>
2660- struct is_pair_of_contiguous_indices ;
2661-
2662- template <class T , class A >
2663- struct is_pair_of_contiguous_indices <T, A> : std::true_type
2659+ template <class T , T... Idx, std::size_t ... Is>
2660+ constexpr bool is_pair_of_contiguous_indices_impl (std::index_sequence<Is...>) noexcept
26642661 {
2665- };
2662+ constexpr T idx[] = { Idx... };
2663+ return (... && (idx[2 * Is] % 2 == 0 && idx[2 * Is] + 1 == idx[2 * Is + 1 ]));
2664+ }
26662665
2667- template <class T , class A , T Idx0, T Idx1, T... Idx>
2668- struct is_pair_of_contiguous_indices <T, A, Idx0, Idx1, Idx...> : std:: conditional_t <(Idx0 % 2 == 0 ) && (Idx0 + 1 == Idx1), is_pair_of_contiguous_indices<T, A, Idx...>, std::false_type>
2666+ template <class T , T... Idx>
2667+ constexpr bool is_pair_of_contiguous_indices () noexcept
26692668 {
2670- };
2671-
2672- template <class T , class A , T... Idx>
2673- inline constexpr bool is_pair_of_contiguous_indices_v = is_pair_of_contiguous_indices<T, A, Idx...>::value;
2669+ static_assert (sizeof ...(Idx) % 2 == 0 , " indices come in pairs" );
2670+ return is_pair_of_contiguous_indices_impl<T, Idx...>(std::make_index_sequence<sizeof ...(Idx) / 2 >());
2671+ }
26742672
26752673 template <class A , uint16_t I0 , uint16_t I1 , uint16_t I2 , uint16_t I3 , uint16_t I4 , uint16_t I5 , uint16_t I6 , uint16_t I7 ,
26762674 uint16_t I8 , uint16_t I9 , uint16_t I10 , uint16_t I11 , uint16_t I12 , uint16_t I13 , uint16_t I14 , uint16_t I15 ,
@@ -2703,7 +2701,7 @@ namespace xsimd
27032701 template <class A , uint16_t ... Idx>
27042702 XSIMD_INLINE batch<uint16_t , A> swizzle (batch<uint16_t , A> const & self, batch_constant<uint16_t , A, Idx...> mask, requires_arch<avx512f>) noexcept
27052703 {
2706- if constexpr (detail::is_pair_of_contiguous_indices_v <uint16_t , A, Idx...>)
2704+ if constexpr (detail::is_pair_of_contiguous_indices <uint16_t , Idx...>() )
27072705 {
27082706 constexpr typename detail::fold_batch_constant<A, Idx...>::type mask32;
27092707 return _mm512_permutexvar_epi32 (static_cast <batch<uint32_t , A>>(mask32), self);
0 commit comments