#include template struct bit; template <> struct bit<0> { static unsigned const value = 0; }; template <> struct bit<1> { static unsigned const value = 1; }; template struct binary { static unsigned const value = binary::value * 2 + bit::value; }; template <> struct binary<0> { static unsigned const value = 0; }; int main() { std::cout << binary<0>::value << std::endl; std::cout << binary<1>::value << std::endl; std::cout << binary<10>::value << std::endl; std::cout << binary<11>::value << std::endl; std::cout << binary<100>::value << std::endl; std::cout << binary<102>::value << std::endl; while(1); return 0; }