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
2
votes
2 answers

Storing boost function

I have to store a list of different boost::function objects. To provide this I'm using boost::any. I have a few functions which takes different functions signatures, pack them into any and then insert into special map with given type. Here is the…
Max Frai
  • 61,946
  • 78
  • 197
  • 306
2
votes
2 answers

Sending Python function as Boost.Function argument

Things are getting complicated in my world of trying to mesh Python code with my C++. Essentially, I want to be able to assign a callback function to be used after an HTTP call receives a response, and I want to be able to do this from either C++ or…
Colin Basnett
  • 4,052
  • 2
  • 30
  • 49
2
votes
3 answers

Pointers to functions

I have to pass function into pointer. For this purposes I'm using boost::function. The function which catches the pointer is overloaded for different signatures. For example: void Foo(boost::function) { ... } void Foo(boost::function
Max Frai
  • 61,946
  • 78
  • 197
  • 306
2
votes
1 answer

Rewrite boost flavored code in C++11 manner (Boost.Bind, Boost.Function)

I have some legacy code I'd like to rewrite in C++11 style. There are some boost::function defined as following // void One::first(int) boost::function a1 = boost::bind(&One::first, this, this->a); // void…
Loom
  • 9,768
  • 22
  • 60
  • 112
2
votes
1 answer

Overloading of C++ functions with similar arguments

I'm trying to create two overloads of the function that takes a handler as the argument: template void foo (Handler h); The first overload should be called if handler takes boost::asio::yield_context as its parameter, template…
Nikki Chumakov
  • 1,215
  • 8
  • 18
2
votes
1 answer

using boost::function with instance methods

I am trying to use boost::function with instance methods using the following example class someclass { public: int DoIt(float f, std::string s1) { return 0; } int test(boost::function funct) …
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
2
votes
2 answers

Passing function pointer arguments with boost

Can the following function pointer passing be simplified/improved with the use of boost::function and/or boost::bind? void PassPtr(int (*pt2Func)(float, std::string, std::string)) { int result = (*pt2Func)(12, "a", "b"); // call using function…
pingu
  • 8,719
  • 12
  • 50
  • 84
2
votes
0 answers

Unwrapping a boost::function from boost::python::object with extract

How can I call C++ module functions from C++ but select the function from python? See example below I know I can setup a map of strings manually, and select the function I want to run, but I'd like a cleaner python solution. I would also like it…
Siren
  • 23
  • 4
2
votes
1 answer

How to safely destruct Posix thread pool in C++

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
2
votes
1 answer

What is wrong with this boost::lambda::bind usage?

Is there something wrong in this code? I keep getting compilation errors. Basically I want to connect a void returning function to a signal which has a non void return type. Boost version: Release 1.46.1 #include #include…
Sak
  • 269
  • 1
  • 4
  • 13
1
vote
1 answer

Boost.Bind non-static member

I have the following code, in which Boost.Local uses a function callback to load a mo file. The function is called findMo for me, and I'm trying to bind it to an object so I can retain the side effects I put in private members of moFinder. class…
Jookia
  • 6,544
  • 13
  • 50
  • 60
1
vote
1 answer

boost::bind & boost::function with partial args

I post you an example of what I want to do, that is easier to explain in this way void myPrinter(const char* text, int number){ printf("\n%s %d\n", text, number); } int main() { char…
M4rk
  • 2,172
  • 5
  • 36
  • 70
1
vote
1 answer

boost tuple causing problems with boost bind / boost function?

I figure my issue here is very common, but I just can't quite see what I'm doing wrong here. I'm doing some boost::asio stuff and attempting to write a templated asynchronous read function. Here is a function. template void…
sbrett
  • 606
  • 4
  • 20
1
vote
0 answers

boost::function alike class

I would like to realize a class Function similar to boost::function, the class Function can use like this in main.cpp : #include #include "Function.hpp" int funct1(char c) { std::cout << c << std::endl; return 0; } int main() { …
1
vote
2 answers

Bind function pointer to boost::function object

How can I initialize a boost::function object with a raw function pointer? Metacode extern "C" { class Library { ... }; Library* createLibrary(); } ... void* functionPtr =…
Mythli
  • 5,995
  • 2
  • 24
  • 31