Without spending a long time reviewing the boost source code, could someone give me a quick rundown of how boost bind is implemented?
Without spending a long time reviewing the boost source code, could someone give me
Share
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.
I like this piece of the
bindsource:Tells you almost all you need to know, really.
The
bind_templateheader expands to a list of inlineoperator()definitions. For example, the simplest:We can see the
BOOST_BIND_RETURNmacro expands toreturnat this point so the line is more likereturn l_(type...).The one parameter version is here:
It’s pretty similar.
The
listNclasses are wrappers for the parameter lists. There is a lot of deep magic going on here that I don’t really understand too much though. They have also overloadedoperator()that calls the mysteriousunwrapfunction. Ignoring some compiler specific overloads, it doesn’t do a lot:The naming convention seems to be:
Fis the type of the function parameter tobind.Ris the return type.Ltends to be a list of parameter types. There are also a lot of complications because there are no less than nine overloads for different numbers of parameters. Best not to dwell on that too much.