// MetaProgramming.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <tchar.h>
template <unsigned long N>
struct binary
{
static unsigned const value =
binary<N/10>::value*2 + N%10;
};
template <>
struct binary<0>
{
static unsigned const value = 0;
};
int _tmain(int argc, _TCHAR* argv[])
{
unsigned const one = binary< 1>::value;
unsigned const two = binary< 10>::value;
unsigned const three = binary< 11>::value;
unsigned const four = binary< 100>::value;
unsigned const seven = binary< 111>::value;
unsigned const nine = binary<1001>::value;
printf (" one =%d\n", one );
printf (" two =%d\n", two );
printf (" three =%d\n", three);
printf (" four =%d\n", four );
printf (" seven =%d\n", seven);
printf (" nine =%d\n", nine );
return 0;
}