Skip to content

Commit

Permalink
replace bit_ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
yosupo06 committed Mar 19, 2023
1 parent 4121285 commit 67a9897
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions atcoder/internal_bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,29 @@
#include <intrin.h>
#endif

#if __cplusplus >= 202002L
#include <bit>
#endif

namespace atcoder {

namespace internal {

#if __cplusplus >= 202002L

using std::bit_ceil;

#else

// @return same with std::bit::bit_ceil
unsigned int bit_ceil(unsigned int n) {
unsigned int x = 1;
while (x < (unsigned int)(n)) x *= 2;
return x;
}

#endif

// @param n `1 <= n`
// @return same with std::bit::countr_zero
int countr_zero(unsigned int n) {
Expand Down

0 comments on commit 67a9897

Please sign in to comment.