24         typedef typename std::make_unsigned<T>::type Unsigned;
 
   37         return  (
rotLeft(v, 8) & 0x000000FF000000FFULL) |
 
   38                 (
rotLeft(v,24) & 0x0000FF000000FF00ULL) |
 
   39                 (
rotLeft(v,40) & 0x00FF000000FF0000ULL) |
 
   40                 (
rotLeft(v,56) & 0xFF000000FF000000ULL);
 
   46         typedef typename std::make_unsigned<T>::type Unsigned;
 
   47         return (T)
swap((Unsigned)v);
 
   65     static UInt 
fromPartsLittle(
const uint8* p)             { UInt val = 0; mt::for_<0, sizeof(UInt)>([&](
int i) { val |= (UInt)p[i] << i*8; }); 
return val; }
 
   67     static UInt 
fromPartsBig(
const uint8* p)                { UInt val = 0; mt::for_<0, sizeof(UInt)>([&](
int i) { val |= (UInt)p[i] << (
sizeof(UInt)-1-i)*8; }); 
return val; }
 
   70     static void toPartsLittle(
const UInt v, 
uint8* p)       { mt::for_<0, sizeof(UInt)>([&](
int i) { p[i] = (
uint8)(v >> i*8); }); }
 
   72     static void toPartsBig(
const UInt v, 
uint8* p)          { mt::for_<0, sizeof(UInt)>([&](
int i) { p[i] = (
uint8)(v >> (
sizeof(UInt)-1-i)*8); }); }
 
   77         x -= (x >> 1) & 0x55555555;
 
   78         x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
 
   79         x = (x + (x >> 4)) & 0x0f0f0f0f;
 
   82         return x & 0x0000003f;
 
   86         x -= (x >> 1) & 0x5555555555555555;             
 
   87         x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333); 
 
   88         x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f;        
 
   97     static bool isPow2(UInt x)                              { 
return !((x-1) & x); }
 
  107     static int log2Floor(
uint64 x)                          { x|=(x>>1); x|=(x>>2); x|=(x>>4); x|=(x>>8); x|=(x>>16); x|=(x>>32); 
return x ? 
popCount(x>>1) : -1; }
 
  109     static int log2Ceil(
uint32 x)                           { 
int32 y=(x&(x-1)); y|=-y; y>>=(32-1); x|=(x>>1); x|=(x>>2); x|=(x>>4); x|=(x>>8); x|=(x>>16); 
return x ? 
popCount(x>>1)-y : -1; }
 
  110     static int log2Ceil(
uint64 x)                           { 
int64 y=(x&(x-1)); y|=-y; y>>=(64-1); x|=(x>>1); x|=(x>>2); x|=(x>>4); x|=(x>>8); x|=(x>>16); x|=(x>>32); 
return x ? 
popCount(x>>1)-int(y) : -1; }
 
  115         v = (v & 0xF0) >> 4 | (v & 0x0F) << 4;
 
  116         v = (v & 0xCC) >> 2 | (v & 0x33) << 2;
 
  117         v = (v & 0xAA) >> 1 | (v & 0x55) << 1;
 
  122         v = (v & 0xFF00) >> 8 | (v & 0x00FF) << 8;
 
  123         v = (v & 0xF0F0) >> 4 | (v & 0x0F0F) << 4;
 
  124         v = (v & 0xCCCC) >> 2 | (v & 0x3333) << 2;
 
  125         v = (v & 0xAAAA) >> 1 | (v & 0x5555) << 1;
 
  130         v = (v & 0xFFFF0000) >> 16 | (v & 0x0000FFFF) << 16;
 
  131         v = (v & 0xFF00FF00) >> 8  | (v & 0x00FF00FF) << 8;
 
  132         v = (v & 0xF0F0F0F0) >> 4  | (v & 0x0F0F0F0F) << 4;
 
  133         v = (v & 0xCCCCCCCC) >> 2  | (v & 0x33333333) << 2;
 
  134         v = (v & 0xAAAAAAAA) >> 1  | (v & 0x55555555) << 1;
 
  139         v = (v & 0xFFFFFFFF00000000) >> 32 | (v & 0x00000000FFFFFFFF) << 32;
 
  140         v = (v & 0xFFFF0000FFFF0000) >> 16 | (v & 0x0000FFFF0000FFFF) << 16;
 
  141         v = (v & 0xFF00FF00FF00FF00) >> 8  | (v & 0x00FF00FF00FF00FF) << 8;
 
  142         v = (v & 0xF0F0F0F0F0F0F0F0) >> 4  | (v & 0x0F0F0F0F0F0F0F0F) << 4;
 
  143         v = (v & 0xCCCCCCCCCCCCCCCC) >> 2  | (v & 0x3333333333333333) << 2;
 
  144         v = (v & 0xAAAAAAAAAAAAAAAA) >> 1  | (v & 0x5555555555555555) << 1;
 
  150 namespace endian { 
namespace priv
 
  152     template<
class Float>
 
  156         mt::for_<0, sizeof(Float)>([&](
int i) { val.bytes[i] = p[i]; });
 
  160     template<
class Float>
 
  164         mt::for_<0, sizeof(Float)>([&](
int i) { val.bytes[i] = p[
sizeof(
Float)-1-i]; });
 
  168     template<
class Float>
 
  173         mt::for_<0, sizeof(Float)>([&](
int i) { p[i] = val.bytes[i]; });
 
  176     template<
class Float>
 
  177     inline void toPartsSwap(
const Float f, 
uint8* p)
 
  181         mt::for_<0, sizeof(Float)>([&](
int i) { p[i] = val.bytes[
sizeof(
Float)-1-i]; });
 
  186 template<
int Endian> 
struct BitOpEndian {};
 
  215     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  216     static T 
fromPartsLittle(
const uint8* p)                { 
return (T)BitOpCommon::fromPartsLittle<typename std::make_unsigned<T>::type>(p); }
 
  217     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  221     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  222     static T 
fromPartsBig(
const uint8* p)                   { 
return (T)BitOpCommon::fromPartsBig<typename std::make_unsigned<T>::type>(p); }
 
  223     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  227     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  229     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  233     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  235     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  257     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  258     static T 
fromPartsLittle(
const uint8* p)                { 
return (T)BitOpCommon::fromPartsLittle<typename std::make_unsigned<T>::type>(p); }
 
  259     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  262     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  263     static T 
fromPartsBig(
const uint8* p)                   { 
return (T)BitOpCommon::fromPartsBig<typename std::make_unsigned<T>::type>(p); }
 
  264     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  267     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  269     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
  272     template<class T, typename std::enable_if<std::is_integral<T>::value, 
int>::type=0>
 
  274     template<class T, typename std::enable_if<std::is_floating_point<T>::value, 
int>::type=0>
 
static uint16 high(const uint32 v)
Definition: BitOp.h:52
 
static UInt pow2Floor(UInt x)
Calc nearest power of two <= unsigned integer. 
Definition: BitOp.h:100
 
static T fromPartsBig(const uint8 *p)
Definition: BitOp.h:263
 
static void toPartsBig(const T v, uint8 *p)
Definition: BitOp.h:273
 
static uint64 pow2Ceil(uint64 x)
Definition: BitOp.h:103
 
static void toPartsLittle(const T v, uint8 *p)
Definition: BitOp.h:268
 
static uint16 reverse(uint16 v)
Definition: BitOp.h:120
 
static uint64 swap(const uint64 v)
Definition: BitOp.h:35
 
static void toPartsLittle(const T v, uint8 *p)
Convert a full number into an array of smaller number parts, where the first index holds the least si...
Definition: BitOp.h:228
 
Float_::Real Float
float type 
Definition: Float.h:61
 
static Int platformToBig(const Int v)
Convert integer from platform endian to big endian. 
Definition: BitOp.h:208
 
static int log2Ceil(uint64 x)
Definition: BitOp.h:110
 
Bit util common to any endian type. Use through class BitOp. 
Definition: BitOp.h:18
 
static void toPartsLittle(const UInt v, uint8 *p)
Definition: BitOp.h:70
 
unsigned int uint32
Definition: Core.h:16
 
static Int platformToBig(const Int v)
Definition: BitOp.h:255
 
static bool isPow2(UInt x)
Check if unsigned integer is a power of two. 
Definition: BitOp.h:97
 
static uint32 high(const uint64 v)
Definition: BitOp.h:53
 
static Int bigToPlatform(const Int v)
Definition: BitOp.h:253
 
static T swap(const T v)
Reverse order of bytes in a signed integer. 
Definition: BitOp.h:44
 
BitOpEndian< ENDIAN > BitOp
Provides methods for manipulating bits. 
Definition: BitOp.h:279
 
static uint64 reverse(uint64 v)
Definition: BitOp.h:137
 
static uint16 low(const uint32 v)
Definition: BitOp.h:57
 
static uint8 reverse(uint8 v)
Reverse order of bits in an unsigned integer. 
Definition: BitOp.h:113
 
static UInt fromPartsBig(const uint8 *p)
Definition: BitOp.h:67
 
Bit util specific to endian type. Use through class BitOp. 
Definition: BitOp.h:187
 
static T fromPartsBig(const uint8 *p)
Convert an array of smaller number parts into a full number, where the first index holds the most sig...
Definition: BitOp.h:222
 
unsigned long long uint64
Definition: Core.h:22
 
static int popCount(uint32 x)
Get number of non-zero bits in unsigned integer. 
Definition: BitOp.h:75
 
static void toPartsBig(const T v, uint8 *p)
Convert a full number into an array of smaller number parts, where the first index holds the most sig...
Definition: BitOp.h:234
 
static Endian platformEndian()
Get platform endian type. 
Definition: BitOp.h:194
 
static uint8 low(const uint16 v)
Retrieve low bytes from integer. 
Definition: BitOp.h:56
 
unsigned char uint8
Definition: Core.h:12
 
static uint8 swap(const uint8 v)
Reverse order of bytes in an unsigned integer. 
Definition: BitOp.h:32
 
static int log2Floor(uint64 x)
Definition: BitOp.h:107
 
int int32
Definition: Core.h:15
 
static T fromPartsLittle(const uint8 *p)
Definition: BitOp.h:258
 
static uint32 fromParts(const uint16 hi, const uint16 lo)
Convert smaller integer parts into a full integer. 
Definition: BitOp.h:61
 
static Endian platformEndian()
Definition: BitOp.h:245
 
static Int platformToLittle(const Int v)
Definition: BitOp.h:250
 
static uint8 high(const uint16 v)
Retrieve high bytes from integer. 
Definition: BitOp.h:51
 
static T rotRight(const T v, const int n)
Rotate integer bits cyclically to the right. 
Definition: BitOp.h:29
 
static uint16 swap(const uint16 v)
Definition: BitOp.h:33
 
static Int bigToPlatform(const Int v)
Convert integer from big endian to platform endian. 
Definition: BitOp.h:205
 
static void toPartsBig(const UInt v, uint8 *p)
Definition: BitOp.h:72
 
unsigned short uint16
Definition: Core.h:14
 
Numeric type information, use numeral() to get instance safely from a static context. 
Definition: Numeral.h:17
 
static uint32 pow2Ceil(uint32 x)
Calc nearest power of two >= unsigned integer. 
Definition: BitOp.h:102
 
static int log2Floor(uint32 x)
Calc log base 2 of unsigned integer, rounded down to nearest integer. Returns -1 if x is zero...
Definition: BitOp.h:106
 
static UInt fromPartsLittle(const uint8 *p)
Definition: BitOp.h:65
 
static uint32 reverse(uint32 v)
Definition: BitOp.h:128
 
static uint32 low(const uint64 v)
Definition: BitOp.h:58
 
static T fromPartsLittle(const uint8 *p)
Convert an array of smaller number parts into a full number, where the first index holds the least si...
Definition: BitOp.h:216
 
long long int64
Definition: Core.h:21
 
static Int littleToPlatform(const Int v)
Definition: BitOp.h:248
 
static uint32 swap(const uint32 v)
Definition: BitOp.h:34
 
static uint64 fromParts(const uint32 hi, const uint32 lo)
Definition: BitOp.h:62
 
Endian
Endian (byte order) types. 
Definition: BitOp.h:11
 
Global Honeycomb namespace. 
 
static int popCount(uint64 x)
Definition: BitOp.h:84
 
static int log2Ceil(uint32 x)
Calc log base 2 of unsigned integer, rounded up to nearest integer. Returns -1 if x is zero...
Definition: BitOp.h:109
 
static Int platformToLittle(const Int v)
Convert integer from platform endian to little endian. 
Definition: BitOp.h:201
 
static Int littleToPlatform(const Int v)
Convert integer from little endian to platform endian. 
Definition: BitOp.h:198
 
static T rotLeft(const T v, const int n)
Rotate integer bits cyclically to the left. 
Definition: BitOp.h:22