"David Abrahams" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > "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 > > > {}; > cool! The octal "feature" was also discussed in the link above and a good idea was to use the PP to _always_ insert a leading zero, eliminating a potentially very annoying bug..
Secondly, another idea that was presented by Jarkko L. was simply to create a "mega-enum" something like this: enum { b0, b1, }; enum { b00, b01, b10, b11, }; enum { b000, b001, b010, .... } etcetera... as I said, quite a few variantions came up in the previous thread, many along this second version. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost