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

Compute the bit position of the set bit, starting at the compile-time constant, input number. More...

#include <bit_fiddling.hpp>

Public Types

enum  : element_type { value =bit_position<(SetBit>>1u)>::value+1 }
 
typedef unsigned long long element_type
 

Static Public Attributes

constexpr static element_type number =SetBit
 

Detailed Description

template<unsigned long long SetBit>
struct jmmcg::mpl::bit_position< SetBit >

Compute the bit position of the set bit, 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 101 of file bit_fiddling.hpp.

Member Typedef Documentation

◆ element_type

template<unsigned long long SetBit>
typedef unsigned long long jmmcg::mpl::bit_position< SetBit >::element_type

Definition at line 102 of file bit_fiddling.hpp.

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 106 of file bit_fiddling.hpp.

Member Data Documentation

◆ number

template<unsigned long long SetBit>
constexpr static element_type jmmcg::mpl::bit_position< SetBit >::number =SetBit
staticconstexpr

Definition at line 104 of file bit_fiddling.hpp.


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