Project 3 - Currency Type
power10.hpp
1 #ifndef POWER10_HPP_
2 #define POWER10_HPP_
3 
4 // Listing 51-6. Computing a Power of 10 at Compile Time
6 template<class T>
7 T constexpr power10_helper(T n, T result)
8 {
9  return n == T{} ? result : power10_helper(n - T{1}, T{10} * result);
10 }
11 
13 template<class T>
14 T constexpr power10(T n)
15 {
16  return power10_helper(n, T{1});
17 }
18 
19 #endif