Skip to content

Struct hal::bit_mask

ClassList > hal > bit_mask

Represents a bit mask of contiguous bits.

  • #include <bit.hpp>

Public Attributes

Type Name
std::uint32_t position
Where the bit mask starts.
std::uint32_t width
The number of bits after position contained in the mask.

Public Functions

Type Name
constexpr bool operator== (const bit_mask & other)
Comparison operator between this mask and another.
constexpr auto origin () const
Convert bit_mask to a integral representation but with bit position at 0.
constexpr auto value () const
Convert mask to a integral representation.

Public Static Functions

Type Name
consteval bit_mask from ()
Generate, at compile time, a bit_mask that spans the from position1 to position2.
constexpr bit_mask from ()
Generate, at compile time, a single bit width bit_mask at position.
consteval bit_mask from (std::uint32_t position1, std::uint32_t position2)
Generate, at compile time, a bit_mask that spans the from position1 to position2.
constexpr bit_mask from (std::uint32_t position)
Generate, at runtime, a single bit width bit_mask at position.

Public Attributes Documentation

variable position

std::uint32_t hal::bit_mask::position;

variable width

std::uint32_t hal::bit_mask::width;

Public Functions Documentation

function operator==

Comparison operator between this mask and another.

inline constexpr bool hal::bit_mask::operator== (
    const bit_mask & other
) 

Parameters:

  • other - the other mask to compare against

Returns:

true - the masks are the same

Returns:

false - the masks are not the same

function origin

Convert bit_mask to a integral representation but with bit position at 0.

template<std::unsigned_integral T>
inline constexpr auto hal::bit_mask::origin () const

The integral presentation will have 1 bits starting from the position bit up to bit position + width. All other bits will be 0s.

For example:

Template parameters:

  • T - unsigned integral type to hold the bit_mask

Returns:

constexpr auto - bit_mask value as an unsigned integer

function value

Convert mask to a integral representation.

template<std::unsigned_integral T>
inline constexpr auto hal::bit_mask::value () const

The integral presentation will have 1 bits starting from the position bit up to bit position + width. All other bits will be 0s.

For example:

Template parameters:

  • T - unsigned integral type to hold the mask

Returns:

constexpr auto - mask value as an unsigned integer

Public Static Functions Documentation

function from [1/4]

Generate, at compile time, a bit_mask that spans the from position1 to position2.

template<std::uint32_t position1, std::uint32_t position2>
static inline consteval bit_mask hal::bit_mask::from () 

If position1 is the same position2 then the bit_mask will have length of 1 and the bit position will be the value of position1.

position1 and position2 can be in any order so long as they span the distance from the start and end of the bit_mask range.

Template parameters:

  • position1 - bit position 1
  • position2 - bit position 2

Returns:

consteval bit_mask - bit bit_mask represented by the two bit positions

function from [2/4]

Generate, at compile time, a single bit width bit_mask at position.

template<std::uint32_t position>
static inline constexpr bit_mask hal::bit_mask::from () 

Template parameters:

  • position - the bit to make the bit_mask for

Returns:

constexpr bit_mask - bit bit_mask with the position bit set to position

function from [3/4]

Generate, at compile time, a bit_mask that spans the from position1 to position2.

static inline consteval bit_mask hal::bit_mask::from (
    std::uint32_t position1,
    std::uint32_t position2
) 

If position1 is the same position2 then the bit_mask will have length of 1 and the bit position will be the value of position1.

position1 and position2 can be in any order so long as they span the distance from the start and end of the bit_mask range.

Parameters:

  • position1 - bit position 1
  • position2 - bit position 2

Returns:

consteval bit_mask - bit bit_mask represented by the two bit positions

function from [4/4]

Generate, at runtime, a single bit width bit_mask at position.

static inline constexpr bit_mask hal::bit_mask::from (
    std::uint32_t position
) 

Parameters:

  • position - the bit to make the bit_mask for

Returns:

constexpr bit_mask - bit bit_mask with the position bit set to position


The documentation for this class was generated from the following file libraries/include/libhal-util/bit.hpp