aboutsummaryrefslogtreecommitdiff
path: root/src/common/powerof.h
blob: 0f6c6254a59240f07f09c583673a0cb25b3f2339 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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,
    };
  };
}