Questions tagged [boost-function]

A Boost C++ library that provide a family of class templates that are function object wrappers, similar to generalized callbacks.

The Boost.Function library defines boost::function, a class template that is callable like a function, and wraps another callable type and forwards calls to it.

Boost.Function was proposed for standardisation and was included in the Technical Report on C++ Library Extensions () as std::tr1::function and included in the C++ 2011 standard as std::function ().

162 questions
0
votes
1 answer

boost::bind() a member function to boost::function with object pointer as placeholder?

I am using boost v1.37 on MSVC7. I'm stuck on these old versions and cannot upgrade so please help me work within my means here and do not suggest upgrades as an answer. I have a class with three member functions. I want to define a boost::function…
void.pointer
  • 24,859
  • 31
  • 132
  • 243
0
votes
2 answers

using boost::function to save function pointer to arbitrary object's member functions

I am trying to store a member function from an object to call it when an appropriate event happens. Unfortunately this code gives a lot of error messages. Can anybody help me? class MainPage { public: MainPage::MainPage(void) { …
DalekSupreme
  • 1,493
  • 3
  • 19
  • 32
0
votes
1 answer

boost::bind implicit conversion to boost::function or function pointer

I'm using boost::function like this: template void run(boost::function func, string arg) { T1 p1 = parse(arg); func(p1); } When used like this, everything is ok: void test1(int i) { cout << "test1 i=" << i <<…
anorm
  • 2,255
  • 1
  • 19
  • 38
0
votes
1 answer

Using boost::bind to call a function in boost::Statechart

I'm trying to write a program to upload a file to an arduino. The program can open a serial port and receive data from the arduino. The problem comes when I try to use a callback to a function in a statechart state, the program crashes. I have…
Andre
  • 115
  • 1
  • 7
0
votes
2 answers

"corrupted double-linked list" on boost::function free()

I am going to try to ask this question without supplying too much source code because all the relevant bits add up to a bunch. The key (I think?) objects involved are using namespace o2scl; typedef…
HazyBlueDot
  • 125
  • 1
  • 12
0
votes
1 answer

How to get the arguments binded into boost::function?

From the boost::bind docs( http://www.boost.org/doc/libs/1_53_0/libs/bind/bind.html#with_functions ), "The arguments that bind takes are copied and held internally by the returned function object", but if there's a way I could get the arguments…
cyber4ron
  • 468
  • 5
  • 7
0
votes
2 answers

Crash related to boost::function usage in thread pool

I am trying to implement thread pool in C++ using pthread. I want to encapsulate logic related to threads management in one object which is taking ownership of these threads. That means whenever this object is destroyed, threads must be stopped and…
Marcin
  • 279
  • 1
  • 4
  • 13
0
votes
1 answer

multiple callback handlers

Consider the snippet: # include # include # include # include # include # include # include # include…
ma740988
  • 11
  • 3
0
votes
1 answer

C++ Functors and Zero

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…
ohnnyj
  • 53
  • 2
  • 6
0
votes
1 answer

"not declared in scope" error in a header file with templates

So, I create a header file that has the following: namespace A { template void foo(...) { //This throws a "test was not declared in this scope" error: boost::function< bool (int, int)> t = test; } template bool test(int…
Andrew Spott
  • 3,457
  • 8
  • 33
  • 59
0
votes
1 answer

How to get a class member to behave like a function pointer using Boost

I would like to have a class member function behave like a function pointer. I need this behavior to integrate my own classes into some existing code. It seems that this may be possible using Boost::function and Boost::bind, but I can't seem to get…
slaughter98
  • 1,759
  • 14
  • 20
0
votes
3 answers

How can I access class instance(object) pointer in "boost::function"?

CClass inst; boost::function func = boost::bind(&CClass::Foo, &inst, _1); In this situation, I want to access inst's pointer(&inst) or address from "func" like below. CClass* pInstance = func.obj_ptr; (This is just a form that I…
winnerrrr
  • 669
  • 1
  • 7
  • 10
1 2 3
10
11