constexpr functions are not allowed to have static variables, and if they are constexpr anyways then them being static has no benifit (#677)

master
Glyn Leine 2022-03-29 17:46:49 +02:00 committed by GitHub
parent b9ff9fa6d9
commit a752d920d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -99,10 +99,10 @@ constexpr std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::va
int> popcount(T val) noexcept
{
using fast_type = typename detail_::fast_utype<T>::type;
static constexpr fast_type b01010101{detail_::repbits<fast_type>(0x55)};
static constexpr fast_type b00110011{detail_::repbits<fast_type>(0x33)};
static constexpr fast_type b00001111{detail_::repbits<fast_type>(0x0f)};
static constexpr fast_type b00000001{detail_::repbits<fast_type>(0x01)};
constexpr fast_type b01010101{detail_::repbits<fast_type>(0x55)};
constexpr fast_type b00110011{detail_::repbits<fast_type>(0x33)};
constexpr fast_type b00001111{detail_::repbits<fast_type>(0x0f)};
constexpr fast_type b00000001{detail_::repbits<fast_type>(0x01)};
fast_type v{fast_type{val} - ((fast_type{val} >> 1) & b01010101)};
v = (v & b00110011) + ((v >> 2) & b00110011);