boost-bind

How does boost bind work behind the scenes in general?

Without spending a long time reviewing the boost source code, could someone give me a quick rundown of how boost bind is implemented? ...

How to use boost::bind in C++/CLI to bind a member of a managed class

I am using boost::signal in a native C++ class, and I now I am writing a .NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as .NET events. When I try to use boost::bind to take the address of a member function of my managed class, I get compiler error 3374, saying I cannot take the address of a member function unless...

Multithreading using the boost library

Wish to simultaneously call a function multiple times. I wish to use threads to call a function which will utilize the machines capability to the fullest. This is a 8 core machine, and my requirement is to use the machine cpu from 10% to 100% or more. My requirement is to use the boost class. Is there any way I can accomplish this usi...

boost::bind with functions that have parameters that are references

I noticed that when passing reference parameters to boost bind, those parameters won't act like references. Instead boost creates another copy of the member and the original passed in variable remains unchanged. When I change the references to pointers, everything works ok. My question is: Is it possible to get references to work, o...

A more natural boost::bind alternative?

Don't get me wrong: Boost's bind() is great. But I do hate to write&read code with it, and I've given up hope my coworkers will ever grok/use it. I end up with code like this: btn.clicked.connect(bind(&BetBar::placeBet, this, bet_id)); animator.eachFrame.connect(bind(&Widget::move, buttons[bet_id])); Which, while logical, is very fa...

Boost lambda bewilderment

Why is callback called once only? bool callback() { static bool res = false; res = !res; return res; } int main(int argc, char* argv[]) { vector<int> x(10); bool result=false; for_each(x.begin(),x.end(),var(result)=var(result)||bind(callback)); return 0; } ...

Determine object and method in a functor using boost::function and boost::bind

I'd like to obtain the pointer to the object and an indication of which method the functor will call from a functor constructed using boost::function and boost::bind. This will allow me to automatically determine the order in a which bunch of functors must be executed. The following (pseudo) code (see POINTER_OF & METHOD_OF) shows what ...

Calling a function with different number of threads passed to the application

I have a function which needs to be invoked with a different number of threads each time (am doing some performance calculation, so need to know when the performance starts deteriorating). Example is given below: getTime() { return 0; } int main() { boost::threadpool::thread_pool<> threads(nThreads); for(int j = 0; j <= nL...

Problem with boost::bind and member function returning auto_ptr

Why does this code fail to compile with VS 2005: #include <boost/bind.hpp> #include <boost/function.hpp> struct X { typedef std::auto_ptr<int> IntType; // typedef int IntType; // this works IntType memfunc () const { return IntType (); } X () { boost::bind (&X::memfunc, this); } }; wi...

Is there a QPointer specialization for boost::bind

boost::bind handles boost::shared_ptr the same way as raw pointers. QObject * object(new QObject); boost::shared_ptr<QObject> sharedObject(new QObject); bind(&QObject::setObjectName, object, _1)( "name" ); bind(&QObject::setObjectName, sharedObject, _1)( "name" ); I would love to have a boost::bind that handles QPointers as raw poi...

boost::bind and class member function

Hello! Consider following example. #include <iostream> #include <algorithm> #include <vector> #include <boost/bind.hpp> void func(int e, int x) { std::cerr << "x is " << x << std::endl; std::cerr << "e is " << e << std::endl; } struct foo { std::vector<int> v; void calc(int x) { std::for_each(v.begin(), v.en...

Can I boost::bind() to an Objective C function?

I have no idea if this is possible, but if it is, what would the syntax look like? If not possible, why not? ...

How do you pass boost::bind objects to a function?

I have a one-dimensional function minimizer. Right now I'm passing it function pointers. However many functions have multiple parameters, some of which are held fixed. I have implemented this using functors like so template <class T> minimize(T &f) { } Functor f(param1, param2); minimize<Functor>(f); However the functor definition...

Is it possible to get the debugger to display the name of the function pointed to by a boost function object?

When debugging code using boost function and bind in Visual Studio, I would like to be able to have the debugger show information about the actual function pointed to by the boost functor. For instance the name of the function, the signature of the original function (before bind was used on it), or the state of the functor. At the momen...

C++ Functors and Zero

Hello all: First a disclaimer, I am replacing a bunch of code which uses boost::function and boost::bind. However, I am moving to a codebase which does not allow rtti. I would like to keep using boost but don't know if there is a way around this restriction. So..., I am trying to mimic some of its functionality, but much more simplif...

Binding to a member variable

Hi, I am confused as to what boost::bind does when we bind to member variables. With binding to member function, we essentially create a function object, and then call it passing to it the arguments that are provided or delayed and substituted via placeholders. But what does this expression do behind the scenes: boost::bind(&std::pair...

Calling base class definition of virtual member function with function pointer

I want to call the base class implementation of a virtual function using a member function pointer. class Base { public: virtual void func() { cout << "base" << endl; } }; class Derived: public Base { public: void func() { cout << "derived" << endl; } void callFunc() { void (Base::*fp)() = &Base::func; ...

delete boost function while in use

I have a situation where a boost::function and boost::bind (actually a std::tr1::function and bind) are being deleted while still in use. Is this safe? I would normally avoid it, but the offending code is a bit entrenched and my only other option is adding a new thread. typedef function<int(int)> foo_type; foo_type* global_foo = NULL...

How do declare an extern "C" function pointer

So I have this code: #include "boost_bind.h" #include <math.h> #include <vector> #include <algorithm> double foo(double num, double (*func)(double)) { return 65.4; } int main(int argc, char** argv) { std::vector<double> vec; vec.push_back(5.0); vec.push_back(6.0); std::transform(vec.begin(), vec.end(), vec.begin(), boost::bi...

null pointer when getting function pointer using boost::function::target

After reading this answer I thought I had a solution. At least the answer there is what I would like to do but I'm having a problem with the implementation. here is an outline of what I am trying to do typedef map<string, double*> myMap; typedef int (*ftwpt)(const char*, const struct stat*, int); typedef boost::function<int(const char...