-
August 23rd, 2017, 06:08 AM
#1
What exaxctly does boost::bind do ??
What does boost:bind do? I've never really thought about it before (I simply took it for granted) but apparently, this statement is perfectly valid code...
Code:
boost::bind(some_function_name);
but what exactly does it do
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
August 23rd, 2017, 07:31 AM
#2
Re: What exaxctly does boost::bind do ??
as far as I know, the main reason is to allow composition with nullary functions:
Code:
int foo();
void bar( int c );
int main() {
bar( foo() ); // this is the expression we want to bind
bind( bar, foo )(); // this won't compile, as if calling bar(foo);
bind( bar, foo() )(); // this works, but it's not what we really want ( foo is invoked once at bind time )
bind( bar, bind(foo) )(); // this works: bind turns foo into a nullary bind expression, informing the outer bind that a composition is requested
}
Last edited by superbonzo; August 23rd, 2017 at 07:39 AM.
Reason: improved answer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|