libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::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::LIBJMMCG_VER_NAMESPACE::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 68 of file bit_fiddling.hpp.

Member Typedef Documentation

◆ element_type

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

Definition at line 69 of file bit_fiddling.hpp.

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 73 of file bit_fiddling.hpp.

Member Data Documentation

◆ number

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

Definition at line 71 of file bit_fiddling.hpp.


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