"Fredrik Blomqvist" <[EMAIL PROTECTED]> writes: > Hi there, > > I thought I'd forward this little link: > http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-CPPCompileTimeBinCons > t&forum=totd&id=-1 > (several improved versions of the initial code appear in the thread) > > This has most likely been done before but IMO a boostified version using MPL > and PP could > actually be a useful convenience utility.
Aleksey and I were just discussing this one. As soon as he's done implementing the "for_" algorithm it could look like this: template <unsigned long N> // N must be an *octal* constant struct binary : for_<N, _1, shift_right<_1, int_<3> >, // "forward" state, condition, step plus<bitand_<_1, int_<1> >, _2> // "backward" step > {}; Now binary<01101>::type::value = 13 > (since I also remember the discussions of a roman-number utility for example > :) Left as an exercise for the reader ;-) -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost