Files
2025-10-25 03:02:53 +03:00

3.5 KiB
Raw Permalink Blame History

[bit.count]

22 General utilities library [utilities]

22.11 Bit manipulation [bit]

22.11.7 Counting [bit.count]

1

#

In the following descriptions, let N denote numeric_limits::digits.

🔗

template<class T> constexpr int countl_zero(T x) noexcept;

2

#

Constraints: T is an unsigned integer type ([basic.fundamental]).

3

#

Returns: The number of consecutive 0 bits in the value of x, starting from the most significant bit.

[Note 1:

Returns N if x == 0.

— end note]

🔗

template<class T> constexpr int countl_one(T x) noexcept;

4

#

Constraints: T is an unsigned integer type ([basic.fundamental]).

5

#

Returns: The number of consecutive 1 bits in the value of x, starting from the most significant bit.

[Note 2:

Returns N if x == numeric_limits::max().

— end note]

🔗

template<class T> constexpr int countr_zero(T x) noexcept;

6

#

Constraints: T is an unsigned integer type ([basic.fundamental]).

7

#

Returns: The number of consecutive 0 bits in the value of x, starting from the least significant bit.

[Note 3:

Returns N if x == 0.

— end note]

🔗

template<class T> constexpr int countr_one(T x) noexcept;

8

#

Constraints: T is an unsigned integer type ([basic.fundamental]).

9

#

Returns: The number of consecutive 1 bits in the value of x, starting from the least significant bit.

[Note 4:

Returns N if x == numeric_limits::max().

— end note]

🔗

template<class T> constexpr int popcount(T x) noexcept;

10

#

Constraints: T is an unsigned integer type ([basic.fundamental]).

11

#

Returns: The number of 1 bits in the value of x.