Consider the below code.
int value1 = BOOST_BINARY( 100 111000 01 1 110 );
Can somebody explain how BOOST_BINARY calculates the int value there?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is very, very complicated. This BOOST library uses macros constructed by others macros.
I am going to present you some simplified example of preprocessor programming:
The simplified question:
How to make macro adding 0 or 1 at the beginning of rest – like in this examples:
So – somehow
,must be put between them both arguments in sequence. Well I did this:It really works (at least at gcc): http://ideone.com/EKlTGt
Now imagine how complicated is work done by BOOST folks in their library? Yes, it is very complicated – but use such preprocessor tricks I presented, and maybe many others – I looked at the source of this BOOST library http://www.boost.org/doc/libs/1_46_1/boost/utility/binary.hpp today for the first time (believe or not).