Evo C++ Library v0.5.1
Classes | Functions
EvoBitManipulation

Evo bit manipulation helpers. More...

Classes

struct  Bits< T, TSize >
 Traits and helpers for bit manipulation. More...
 

Functions

template<class T >
uint bits_clz (T mask)
 Get leading zero count on bitmask. More...
 
uint bits_clz16 (uint16 mask)
 Get leading zero count on bitmask (uint16). More...
 
uint bits_clz32 (uint32 mask)
 Get leading zero count on bitmask (uint32). More...
 
uint bits_clz64 (uint64 mask)
 Get leading zero count on bitmask (uint64). More...
 
uint bits_clz8 (uint8 mask)
 Get leading zero count on bitmask (uint8). More...
 
bool bits_cpu_popcnt ()
 Runtime check whether current CPU supports the POPCNT instruction. More...
 
template<class T >
int bits_popcount (T mask)
 Get population count (number of bits set) for value. More...
 

Detailed Description

Evo bit manipulation helpers.

Function Documentation

◆ bits_clz()

uint evo::bits_clz ( mask)
inline

Get leading zero count on bitmask.

  • Caution: Different input sizes can give different results on same value so fixed-size functions like bits_clz32() are often preferred
Template Parameters
TMask type, inferred by param mask
Parameters
maskInput bitmask
Returns
Leading zero count, NONE if mask is 0
See also
bits_clz8(), bits_clz16(), bits_clz32(), bits_clz64()

◆ bits_clz16()

uint evo::bits_clz16 ( uint16  mask)
inline

Get leading zero count on bitmask (uint16).

Template Parameters
TMask type, inferred by param mask
Parameters
maskInput bitmask
Returns
Leading zero count, NONE if mask is 0
See also
bits_clz(), bits_clz8(), bits_clz32(), bits_clz64()

◆ bits_clz32()

uint evo::bits_clz32 ( uint32  mask)
inline

Get leading zero count on bitmask (uint32).

Template Parameters
TMask type, inferred by param mask
Parameters
maskInput bitmask
Returns
Leading zero count, NONE if mask is 0
See also
bits_clz(), bits_clz8(), bits_clz16(), bits_clz64()

◆ bits_clz64()

uint evo::bits_clz64 ( uint64  mask)
inline

Get leading zero count on bitmask (uint64).

Template Parameters
TMask type, inferred by param mask
Parameters
maskInput bitmask
Returns
Leading zero count, NONE if mask is 0
See also
bits_clz(), bits_clz8(), bits_clz16(), bits_clz32()

◆ bits_clz8()

uint evo::bits_clz8 ( uint8  mask)
inline

Get leading zero count on bitmask (uint8).

Template Parameters
TMask type, inferred by param mask
Parameters
maskInput bitmask
Returns
Leading zero count, NONE if mask is 0
See also
bits_clz(), bits_clz16(), bits_clz32(), bits_clz64()

◆ bits_cpu_popcnt()

bool evo::bits_cpu_popcnt ( )
inline

Runtime check whether current CPU supports the POPCNT instruction.

Returns
Whether POPCNT instruction is supported
See also
bits_popcount()

◆ bits_popcount()

int evo::bits_popcount ( mask)
inline

Get population count (number of bits set) for value.

Template Parameters
TMask type (inferred from argument)
Parameters
maskBit mask to use
Returns
Number of bits set in mask