#include <iostream>
using namespace std;
template <int n>
class static_log
{
public:
enum {value = static_log
} ;
template <>
class static_log
{
public:
enum{value =
};
int main()
{
cout<<static_log
cin
}
進一步擴展
#include <iostream>
using namespace std;
template <int base
class static_logxN
{
public:
enum {value = static_logxN<base
} ;
template <int base>
class static_logxN<base
{
public:
enum{value =
};
int main()
{
cout<<static_logxN<
cin
}
From:http://tw.wingwit.com/Article/program/c/201311/11103.html