diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/powerof.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/common/powerof.h b/src/common/powerof.h new file mode 100644 index 000000000..0f6c6254a --- /dev/null +++ b/src/common/powerof.h @@ -0,0 +1,26 @@ +#pragma once + +#include <stdint.h> + +namespace tools +{ + template<uint64_t a, uint64_t b> + struct PowerOf + { + enum Data : uint64_t + { + // a^b = a * a^(b-1) + Value = a * PowerOf<a, b - 1>::Value, + }; + }; + + template<uint64_t a> + struct PowerOf<a, 0> + { + enum Data : uint64_t + { + // a^0 = 1 + Value = 1, + }; + }; +} |