// -*- C++ -*- #ifndef HL_MODULO_H #define HL_MODULO_H /// A templated class that provides faster modulo functions when the /// argument is a power of two. #include #include "checkpoweroftwo.h" namespace HL { template class Modulo; template class Modulo { public: template static TYPE mod (TYPE m) { if (IsPowerOfTwo::VALUE) { return m & (Modulus - 1); } else { return m % Modulus; } } }; } #endif