//宣言ヘッダー
#include 実装ヘッダー
namespace MY_TEST_TMP_HEADER{
int factorial(int n);
template<unsigned n> struct Factorial;
template<> struct Factorial<0>;
}
//実装ヘッダー
namespace MY_TEST_TMP_HEADER{
int factorial(int n){
int value = 0;
while(n)
value += n--;
return value;
}
template<unsigned n>
struct Factorial{
enum {value = n + Factorial<n-1>::value};
};
template<>
struct Factorial<0>{
enum {value = 0};
};
}
個人的にはコンパイル時間:factorial < sturct Factorial ; 実行時間:factorial > sturct Factorial だと思いますが、どうでしょう?