@@ -19,24 +19,24 @@ namespace xsimd
1919{
2020 namespace utils
2121 {
22- template <typename I, typename ... Args>
23- constexpr I make_bit_mask (I bit, Args... bits)
22+ template <typename ... Args>
23+ constexpr auto make_bit_mask (Args... bits)
2424 {
25- static_assert ( std::is_unsigned_v<I>, " Bit operations must be done on unsigned integers " ) ;
26- [[maybe_unused]] constexpr I bit_count = static_cast <I >(8 * sizeof (I ));
27- assert (((bit < bit_count) && ... && ( static_cast <I>(bits) < bit_count )));
28- return static_cast <I >(((I { 1 } << bit) | ... | (I { 1 } << static_cast <I>( bits) )));
25+ using out_type = std::common_type_t < unsigned short , std:: make_unsigned_t <Args>...> ;
26+ [[maybe_unused]] constexpr auto bit_count = static_cast <out_type >(8 * sizeof (out_type ));
27+ assert (((( static_cast <out_type>(bits) < bit_count) && ...)));
28+ return static_cast <out_type >((0u | ... | (1u << bits)));
2929 }
3030
31- template <int ... Bits, typename I>
31+ template <auto ... Bits, typename I>
3232 constexpr bool all_bits_set (I value)
3333 {
3434 static_assert (std::is_unsigned_v<I>, " Bit operations must be done on unsigned integers" );
3535 constexpr I mask = make_bit_mask<I>(static_cast <I>(Bits)...);
3636 return (value & mask) == mask;
3737 }
3838
39- template <int Bit, typename I>
39+ template <auto Bit, typename I>
4040 constexpr I set_bit (I value)
4141 {
4242 static_assert (std::is_unsigned_v<I>, " Bit operations must be done on unsigned integers" );
0 commit comments