libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::mpl::lsb_bitmask< MSetBit > Struct Template Reference

Create a bitmask of a contiguous block of zeros, then ones, starting at the compile-time constant, input number. More...

#include <bit_fiddling.hpp>

Public Types

enum  : element_type { value =MSetBit|(lsb_bitmask<(MSetBit>>1u)>::value) }
 
typedef unsigned long long element_type
 

Static Public Attributes

constexpr static element_type number =MSetBit
 

Detailed Description

template<unsigned long long MSetBit>
struct jmmcg::mpl::lsb_bitmask< MSetBit >

Create a bitmask of a contiguous block of zeros, then ones, starting at the compile-time constant, input number.

Because the operator>>() is poorly defined this only works for unsigned types. This is because there may be a sign bit or two's complement representation of the negative number. Then shifting might cause the sign bit to be shifted into the number itself, possibly causing an infinite loop.

Complexity: compile-time: O(n) where n is at most the number of bits used to represent the input type. run-time: O(1) Space: O(1)

Definition at line 67 of file bit_fiddling.hpp.

Member Typedef Documentation

◆ element_type

template<unsigned long long MSetBit>
typedef unsigned long long jmmcg::mpl::lsb_bitmask< MSetBit >::element_type

Definition at line 85 of file bit_fiddling.hpp.

Member Enumeration Documentation

◆ anonymous enum

template<unsigned long long MSetBit>
anonymous enum : element_type
Enumerator
value 

Definition at line 89 of file bit_fiddling.hpp.

Member Data Documentation

◆ number

template<unsigned long long MSetBit>
constexpr static element_type jmmcg::mpl::lsb_bitmask< MSetBit >::number =MSetBit
staticconstexpr

Definition at line 87 of file bit_fiddling.hpp.


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