Bit manipulation utilities. More...
| Functions | |
| template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| constexpr bool | has_bit (uint_t b) noexcept | 
| Does the type Int have the bit b? note: used to assert if bit is within bounds. | |
| template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| constexpr bool | get (Int x, uint_t b) | 
| Gets the value of the i-thbit of the integerx. | |
| template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| constexpr void | set (Int &x, uint_t b, bool value) | 
| Sets the i-thbit ofxtovalue. | |
| template<typename Int , Int max = width<Int>, CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| constexpr auto | to_int (Int x, Int from=0, Int to=max) -> Int | 
| Integer representation of the bit range [from, to) of x. | |
| template<typename Int , Int max = width<Int>, CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| constexpr auto | to_int_r (Int x, Int from=0, Int to=max) -> Int | 
| Reverse integer representation of the bit range [from, to) of x TODO: clean this up. | |
| template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| constexpr void | swap (Int &x, uint_t b0, uint_t b1) | 
| Swaps the bits aandbinx. | |
| template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) > | |
| auto | bits () noexcept | 
| Range of bit positions for type.  More... | |
| constexpr uint64_t | max_value (uint64_t no_bits) | 
| Maximum representable unsigned integer value in no_bits.  More... | |
| template<typename UInt , typename SInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}and SignedIntegral< SInt >{}) and bit::width< UInt > = = bit::width<SInt>> | |
| constexpr bool | overflows_on_add (UInt value, SInt offset, UInt no_bits=width< UInt >) | 
| Does adding offsetto the firstno_bitsofvalueoverflows? | |
| template<typename UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) > | |
| constexpr bool | overflows_on_add (UInt value, UInt offset, UInt no_bits=width< UInt >) | 
| Does adding offsetto the firstno_bitsofvalueoverflows? | |
| template<typename Integral > | |
| constexpr Integral | deposit_bits (Integral x, Integral mask) | 
| Parallel Bits Deposit. | |
| template<typename Integral > | |
| constexpr Integral | extract_bits (Integral x, Integral mask) | 
| Parallel Bits Extract. | |
| Variables | |
| template<typename Int > | |
| constexpr auto | width = static_cast<Int>(CHAR_BIT * sizeof(Int{})) | 
| Bit width of type Int. | |
Bit manipulation utilities.
| 
 | noexcept | 
Range of bit positions for type.
| Int | TODO: make this constexpr | 
| constexpr uint64_t ndtree::v1::bit::max_value | ( | uint64_t | no_bits | ) | 
Maximum representable unsigned integer value in no_bits. 
Formula: 2^{n} - 1
Since 2^{n} might not fit in the integer type it uses the following relation: 2^{n} - 1 = 2^{n - 1} * 2 - 1 = 2^{n - 1} + (2^{n - 1} - 1)
References ndtree::v1::math::ipow().
Referenced by overflows_on_add().