libstdc++
Bit manipulation
Collaboration diagram for Bit manipulation:

Macros

#define __cpp_lib_bit_cast
 
#define __cpp_lib_bitops
 
#define __cpp_lib_endian
 
#define __cpp_lib_int_pow2
 

Enumerations

enum class  std::endian { little , big , native }
 

Functions

template<typename _To , typename _From >
constexpr _To std::bit_cast (const _From &__from) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp > std::bit_ceil (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp > std::bit_floor (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp > std::bit_width (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp, int > std::countl_one (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp, int > std::countl_zero (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp, int > std::countr_one (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp, int > std::countr_zero (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp, bool > std::has_single_bit (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp, int > std::popcount (_Tp __x) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp > std::rotl (_Tp __x, int __s) noexcept
 
template<typename _Tp >
constexpr _If_is_unsigned_integer< _Tp > std::rotr (_Tp __x, int __s) noexcept
 

Detailed Description

Utilities for examining and manipulating individual bits.

Enumeration Type Documentation

◆ endian

enum std::endian
strong

Byte order.

Definition at line 444 of file bit.

Function Documentation

◆ bit_cast()

template<typename _To , typename _From >
constexpr _To std::bit_cast ( const _From &  __from)
constexprnoexcept

Create a value of type To from the bits of from.

Definition at line 75 of file bit.

◆ bit_ceil()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp> std::bit_ceil ( _Tp  __x)
constexprnoexcept

The smallest power-of-two not less than x.

Definition at line 426 of file bit.

◆ bit_floor()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp> std::bit_floor ( _Tp  __x)
constexprnoexcept

The largest power-of-two not greater than x.

Definition at line 432 of file bit.

◆ bit_width()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp> std::bit_width ( _Tp  __x)
constexprnoexcept

The smallest integer greater than the base-2 logarithm of x.

Definition at line 438 of file bit.

◆ countl_one()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp, int> std::countl_one ( _Tp  __x)
constexprnoexcept

The number of contiguous one bits, starting from the highest bit.

Definition at line 392 of file bit.

◆ countl_zero()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp, int> std::countl_zero ( _Tp  __x)
constexprnoexcept

The number of contiguous zero bits, starting from the highest bit.

Definition at line 386 of file bit.

◆ countr_one()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp, int> std::countr_one ( _Tp  __x)
constexprnoexcept

The number of contiguous one bits, starting from the lowest bit.

Definition at line 404 of file bit.

◆ countr_zero()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp, int> std::countr_zero ( _Tp  __x)
constexprnoexcept

The number of contiguous zero bits, starting from the lowest bit.

Definition at line 398 of file bit.

◆ has_single_bit()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp, bool> std::has_single_bit ( _Tp  __x)
constexprnoexcept

True if x is a power of two, false otherwise.

Definition at line 420 of file bit.

Referenced by std::assume_aligned().

◆ popcount()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp, int> std::popcount ( _Tp  __x)
constexprnoexcept

The number of bits set in x.

Definition at line 410 of file bit.

◆ rotl()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp> std::rotl ( _Tp  __x,
int  __s 
)
constexprnoexcept

Rotate x to the left by s bits.

Definition at line 372 of file bit.

◆ rotr()

template<typename _Tp >
constexpr _If_is_unsigned_integer<_Tp> std::rotr ( _Tp  __x,
int  __s 
)
constexprnoexcept

Rotate x to the right by s bits.

Definition at line 378 of file bit.