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

C++ template param deduction is not working

I need to override connection between boost::signals2::signal and boost::function. For this purpose I've created following template function: template void bind(boost::signals2::signal &signal, boost::function function) { //…
3
votes
1 answer

Disconnecting a boost signals2 connection by functor

I'm trying to convert some code that used a different system over to use Boost.Signals2. The old code used a regular function pointer as the functor; connections were done by calling a particular method with the functor, and disconnections were…
Miral
  • 12,637
  • 4
  • 53
  • 93
3
votes
1 answer

Trouble with using boost::bind & boost::function

Following on from this question How to pass class member functions to a method in a 3rd party library? Quick recap is I need to pass pointers to functions to the constructor of a class called moveset in a 3rd party library with the definition…
oracle3001
  • 1,090
  • 19
  • 31
2
votes
2 answers

Error C2228 when constructing boost::function object in constructor argument list

The code below does not compile in Visual C++ 2005. class SomeClass { public: boost::function func; SomeClass(boost::function &func): func(func) { } }; void someFunc() { std::cout << "someFunc" << std::endl; } int…
Eddie
2
votes
2 answers

boost::function in VS2010 : error C2039: 'function' : is not a member of 'boost'

INFO I'd like to use boost::function to pass callback as parameter, like this way: void ReadPacket( boost::function callback); and then use it : ReadPacket(boost::bind( …
nix
  • 464
  • 1
  • 5
  • 13
2
votes
2 answers

Boost function and boost bind: Bind the return value?

This is related to this previous question: Using boost::bind with boost::function: retrieve binded variable type. I can bind a function like this: in .h: class MyClass { void foo(int a); void bar(); void execute(char* param); int…
Smash
  • 3,722
  • 4
  • 34
  • 54
2
votes
1 answer

Using std::vector with boost::bind

While trying to get comfortable with boost, stumbled into problem with using boost::function along with std::vector. I'm trying to do a simple thing: have a list of functions with similair signatures and then use all that functions with…
elricbk
  • 107
  • 7
2
votes
3 answers

Choosing between virtual function, function_pointer and functors

I am writing a class in which a one of the function's implementation depends on the users. Currently I have it as a virtual function and users need to override my class to provide its implementation. I am thinking of making it a…
balki
  • 26,394
  • 30
  • 105
  • 151
2
votes
1 answer

C++ Load function from DLL into Boost function

I want to load a particular function from DLL and store it inside the Boost function. Is this possible? typedef void (*ProcFunc) (void); typedef boost::function ProcFuncObj; ACE_SHLIB_HANDLE file_handle = ACE_OS::dlopen("test.dll",…
Gokul
  • 893
  • 11
  • 27
2
votes
1 answer

How to use std::for_each on a range of boost::function objects?

class User { public: User(){} virtual ~User(){} void Test( int in ) { } } User user; vector< boost::function< void() > > functions; functions.push_back( boost::bind( &User::Test, &user, 2 )…
metdoloca
  • 21
  • 2
2
votes
1 answer

Incomplete type using typedef function pointer

I've got an abstract base class that defines an interface to data sinks. Concrete implementations of data sinks are acquired via factories. In an effort to tidy up code, I created a typedef for the factory method that returns new DataSink objects…
Ryan Talbot
  • 115
  • 1
  • 6
2
votes
2 answers

boost::bind and reference to temp variable

Suppose I have method: void foo(const std::string& s); Can I create boost::function: boost::function f = boost::bind(foo, temp); where temp is char* that is deleted before f is called.
dimba
  • 26,717
  • 34
  • 141
  • 196
2
votes
1 answer

Is there a generic "clean-up" class in boost?

I simply want a class that does this: class cleanup : boost::noncopyable { public: typedef boost::function0 function; explicit cleanup( function f ) : func( f ) { } ~cleanup() { func(); } private: function func;…
CashCow
  • 30,981
  • 5
  • 61
  • 92
2
votes
2 answers

boost::function memory usage

I'm considering using boost::function in my implementation of a timer manager. At schedule timer a boost::function will be passed and at the timer expiration the callback will be executed. Times will be scheduled/canceled at a vey high frequency…
dimba
  • 26,717
  • 34
  • 141
  • 196
2
votes
2 answers

boost::function deallocation segmentation fault in thread pool

I'm trying to make a thread pool that blocks the main thread until all it's children have completed. The real-world use-case for this is a "Controller" process that spawns independent processes for the user to interact with. Unfortunately, when the…
Tyler Jandreau
  • 4,245
  • 1
  • 22
  • 47