Created
December 18, 2020 15:07
-
-
Save airglow923/565967bb54e086922baa13f16b41e19b to your computer and use it in GitHub Desktop.
Exponents at compile time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace { | |
using LL = signed long long int; | |
template <LL N, LL X> | |
struct PowerOf { | |
static constexpr LL value_ = N * PowerOf<N, X - 1>::value_; | |
}; | |
template <LL N> | |
struct PowerOf<N, 0> { | |
static constexpr LL value_ = 1; | |
}; | |
} // namespace | |
template <LL N, LL X> | |
inline constexpr LL PowerOfV = PowerOf<N, X>::value_; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment