diff options
author | SChernykh <sergey.v.chernykh@gmail.com> | 2020-10-20 14:16:09 +0200 |
---|---|---|
committer | SChernykh <sergey.v.chernykh@gmail.com> | 2020-10-20 14:16:09 +0200 |
commit | a25bc71f3faf3f7ca4de9eda6342503768bf28ad (patch) | |
tree | 9493846d8297b373769161737fac91f17bb5dcbc /src/common/powerof.h | |
parent | Merge pull request #6891 (diff) | |
download | monero-a25bc71f3faf3f7ca4de9eda6342503768bf28ad.tar.xz |
Make Blockchain::get_fee_quantization_mask() compile time
This also removes potential thread safety bug in that function.
Diffstat (limited to 'src/common/powerof.h')
-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, + }; + }; +} |