// (by Ariel Badichi) #include <iostream>
#include <boost/static_assert.hpp>
template<unsigned int N> struct binary { static const unsigned int digit = N % 10; BOOST_STATIC_ASSERT(digit == 0 || digit == 1); static const unsigned int value = digit + (binary<N / 10>::value * 2); };
template<> struct binary<0> { static const unsigned int value = 0; };
int main() { // add a 2 and see what happens ;) std::cout << binary<101010>::value << "\n"; return 0; }
template<unsigned long N> class binary: public boost::mpl::int_<boost::mpl::int_<binary<N/10>::value>::value<<1 | N%10> {
CTASSERT((N%10 & ~1) == 0);};
template<> class binary<0>: public boost::mpl::int_<0> { };