All pastes #26499 Raw Edit

CN

public cpp v1 · immutable
#26499 ·published 2005-10-24 17:51 UTC
rendered paste body
#include <iostream>template <unsigned long N> struct bit;template <>struct bit<0>{    static unsigned const value = 0;};template <>struct bit<1>{    static unsigned const value = 1;};template <unsigned long N>struct binary{    static unsigned const value        = binary<N/10>::value * 2            + bit<N%10>::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;}