aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-11-29 01:40:59 -0600
committerluigi1111 <luigi1111w@gmail.com>2020-11-29 01:40:59 -0600
commit999e797cea77c9f98fddebf8d25e3ff1b8a7d83a (patch)
treef53fafb369092c2fadbf8cba0efd00f2b8487b2c /src/common
parentbab4495cfbbbd95e4fa3d700b4595f457a7f2190 (diff)
parenta25bc71f3faf3f7ca4de9eda6342503768bf28ad (diff)
downloadmonzero-core-999e797cea77c9f98fddebf8d25e3ff1b8a7d83a.tar.gz
monzero-core-999e797cea77c9f98fddebf8d25e3ff1b8a7d83a.tar.xz
monzero-core-999e797cea77c9f98fddebf8d25e3ff1b8a7d83a.zip
Merge pull request #6922
a25bc71 Make Blockchain::get_fee_quantization_mask() compile time (SChernykh)
Diffstat (limited to 'src/common')
-rw-r--r--src/common/powerof.h26
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,
+ };
+ };
+}