#ifndef BITTOOLS_H #define BITTOOLS_H #ifdef _WIN32 #pragma once #endif namespace bittools { template struct RecurseBit { enum { result = RecurseBit::result }; }; template struct RecurseBit<0, C> { enum { result = C }; }; template struct RecursePow2 { enum { result = RecursePow2::result }; }; template struct RecursePow2<0, C> { enum { result = C }; }; } #define ROUND_TO_POWER_OF_2( n ) ( bittools::RecursePow2< (n) - 1 >::result ) #define MINIMUM_BITS_NEEDED( n ) ( bittools::RecurseBit< (n) - 1 >::result ) #endif