C++ Template Metaprogramming にはこんなのもあるよ。

template <unsigned long N>
struct binary
{
static unsigned const value
= binary<N/10>::value * 2 + N % 10;
}