I am trying to create a copy of a boost::function by using a pointer and call that function using that pointer. My questions are
- cloning a
boost::functionthat way is something correct - the call to
fp->target()should call or not the function wrapped
by the boost::function?
Thanks a lot
boost::function<void()> f = boost::bind(&my_f,my_value);
boost::function<void()> fp* = new boost::function<void()>( f ); // clone f
typedef void(*fptr_type)();
fp->target<fptr_type>(); // doesn't work! Is this correct?
fp->operator(); // doesn't compile
//=>error: statement cannot resolve address of overloaded function
If boost::function provides a copy constructor, you can assume that it will work and take care of all the lifetime issues of f in this case ( otherwise it wouldn’t be provided, and you should file a bug report on their bugzilla ).
Is just the function, what you’re meaning to do is:
Or as above poster: