Sign in to follow this  
ZealousEngine

boost::bind/lambda question

Recommended Posts

Im wondering, how do you create a new/local variable inside a boost::bind? For example, how should something like this be written... boost::bind(( int val; val = boost::bind( &ObjectType::foo, &myObj )(), boost::bind( &ObjectType::goo, &myObj, _1 )( val ) )); The goal is to get a function that looks like - foo(goo()). I know I COULD do this by nesting the binds, but nesting to many binds can get messy fast. I want to buffer the return values in local variables, to make things easier to read. How can I do this? Thanks!

Share this post


Link to post
Share on other sites
boost::bind and boost::lambda get messy. If you don't want the mess, write a real function. That's also messy, but perhaps in a more acceptable way.

Share this post


Link to post
Share on other sites
Im starting to think youre right..

I guess my original logic was all wrong. I shouldnt be trying to encapsulate complex blocks of code in a boost::bind (with the ultimate goal of sending them to another thread to be executed). I should just write the same complex block of code in a traditional function/object, and just send a call back request to the other thread.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this