pabigot  0.1.1
C++ support classes
Public Types | Static Public Member Functions
pabigot::crc::details::uint_traits< C > Struct Template Reference

Extend the size-related traits with functionality operating on the specific types. More...

#include </mnt/devel/pabigot-cxx/include/pabigot/crc.hpp>

Inheritance diagram for pabigot::crc::details::uint_traits< C >:
pabigot::crc::details::uint_size_traits< C >

Public Types

using super = uint_size_traits< C >
 
using fast_limits = std::numeric_limits< fast_type >
 

Static Public Member Functions

static constexpr fast_type reverse (const fast_type &v, unsigned int bits)
 Reverse bits [0..bits) of v. More...
 
static constexpr fast_type mask_for_bits (unsigned int bits)
 Helper to calculate the value of a B-bit mask as an instance of the unsigned type T. More...
 

Detailed Description

template<unsigned int C>
struct pabigot::crc::details::uint_traits< C >

Extend the size-related traits with functionality operating on the specific types.

Specifically, provide the ability to bit-reverse a value stored in the low bits of a word. This supports the requirements of a reflected (LSB-first) algorithm.

Member Function Documentation

◆ mask_for_bits()

template<unsigned int C>
static constexpr fast_type pabigot::crc::details::uint_traits< C >::mask_for_bits ( unsigned int  bits)
inlinestaticconstexpr

Helper to calculate the value of a B-bit mask as an instance of the unsigned type T.

Need this evaluated at compile-time, supporting both cases where T can represent strictly more bits than are needed and where T represents exactly that many bits.

Template Parameters
Tan unsigned integral type.
Parameters
bitsthe number of bits to be masked. If bits is greater than the number of bits representable in T undefined behavior may result.

◆ reverse()

template<unsigned int C>
static constexpr fast_type pabigot::crc::details::uint_traits< C >::reverse ( const fast_type &  v,
unsigned int  bits 
)
inlinestaticconstexpr

Reverse bits [0..bits) of v.

See also
reverse_low_bits

The documentation for this struct was generated from the following file: