
On 9/3/05, Matt Calabrese <rivorus@gmail.com> wrote:
On 9/2/05, Paul Mensonides <pmenso57@comcast.net> wrote:
The problem is that there isn't any arbitrary precision arithmetic support in the pp-lib. If there was, you could do better than that for syntax:
BOOST_BINARY_INT( 1100 0011 1010 )
I do not immediately see how to implement it allowing the syntax you describe (where your nibbles are simply separated by spaces rather than using a Boost.Preprocessor sequence), so if you could, please enlighten me as I know you must be more experienced with the preprocessor (I love Boost.Preprocessor by the way).
Nevermind, I figured out a way to do it myself with lots of macro magic. A version allowing the more simple syntax you originally alluded to is available here: http://www.illegal-immigration.com/Riv/boost/binary_literal.hpp Also, I changed the macro name to BOOST_BINARY_LITERAL Usage is as simple as: BOOST_BINARY_LITERAL( 101 0111 1010 0110 ) The first nibble is allowed to be written with under 4 explicit bits, but the remaining nibbles must use a complete 4 bits each. This was done to avoid confusion. If you wish to append standard integer suffixes, you can use the macro BOOST_SUFFIXED_BINARY_LITERAL Usage for that is: BOOST_SUFFIXED_BINARY_LITERAL( 101 0111 1010 0110, UL ) It should work for integers of any reasonable size, even well beyond 64 bits, and results in a hex literal at preprocessing time. -- -Matt Calabrese