
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of David Abrahams
Matt Calabrese's version is in http://www.illegal-immigration.com/Riv/boost/binary_literal2.hpp. It can be used as: int x = BOOST_BINARY_LITERAL( 101 0111 1010 0110 );
This version looks better to me.
I'm also more inclined towards the macro version (with Paul's suggested name change), although if we got some of the MPL interoperability things that Andy Little mentioned, and of course the absolutely _essential_ documentation, I might be inclined the other way.
I think a template-based version is unacceptable for one primary reason. To the template mechanism, 001 and 0001 are the same thing. That is a bad thing when specifying groups of binary bits, as the groupings are often not simple four-bit groupings. The macro version can differentiate between the two, and can specify any pattern of bit groups. Other then the ability to tack UL (etc.) onto the end, it isn't a great strength that the macro produces a literal--only that it produces a compile-time constant suitably typed. IMO, as far as this is concerned, the template-based version and the macro-based version are more-or-less equivalent. The great strength of the macro version is the support for arbitrary bit groupings. Regards, Paul Mensonides