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
1
vote
1 answer

Problems using mpl::if_, boost::function, and a typedef to void

I'm new to the Boost.MPL library, and have some "beginners-problems" Look at this sample: template < typename F > struct A { typedef boost::function_types::parameter_types P; typedef typename boost::function_types::result_type::type R; …
Allan
  • 4,562
  • 8
  • 38
  • 59
1
vote
2 answers

boost asio compilation error with async functions

I want to create an async. server. i succeed to do that, but now i want to bind async_read/asyn_write functions to caller object function. So i tried to do that with boost::function here you have my code : Server.cpp #include "Server.h" #include…
Adrien A.
  • 441
  • 2
  • 12
  • 31
1
vote
1 answer

Implement no-op functor using boost::bind

I have a function void get(boost::function callback) { callback(); }. I want to make a call like get(boost::bind(/* don't know what to put here*/)); without implementing any other functions, variables or structs, so that the callback…
abyss.7
  • 13,882
  • 11
  • 56
  • 100
1
vote
0 answers

How to keep a registry of variable parameter functions

I'll explain what I'm trying to do: I'm working on a game. In order to handle the graphics, I have a stack of ScreenLayers that I update and draw. The ScreenLayer is responsible for providing visualization for some aspect of the game (inventory,…
Megatron
  • 2,871
  • 4
  • 40
  • 58
1
vote
6 answers

boost function and lambda to wrap a function

I want to convert this simple code: void setZComp(Imath::V3f& pt) { pt.z = 0.0; } int myfunc() { ... std::vector vec(5,Imath::V3f(1.0,1.0,1.0)); std::for_each(vec.begin(),vec.end(),boost::bind(&setZComp,_1)); …
iaiotom
  • 11
  • 1
  • 3
1
vote
1 answer

How to create boost::function from template signature

Recently I was trying to create flexible observer pattern implementation which hides boost::signal. I almost succeeded. I have a Observer class which has to have an update method matching signature provided by template parameter. Example of…
Wojciech
  • 13
  • 3
1
vote
1 answer

Bind a valid class object pointer to boost::function<>fn. What may happen if invoking the `fn` after the object has been destoryed?

Bind a class member function and a valid class object pointer to boost::function<>fn. What may happen if invoking the fn after the object which the pointer pointed to has been destroyed? Are there some potential problems that I should be aware…
John
  • 2,963
  • 11
  • 33
1
vote
2 answers

boost bind to a data member callback behavior

Can someone please explain this piece of code? struct Class { boost::function member; }; Class c; boost::function()> foo = boost::bind(&Class::member, &c); boost::function bar =…
1
vote
1 answer

How to call shared_ptr from a vector in a loop?

I've got a working callback system that uses boost::signal. I'm extending it into a more flexible and efficient callback manager which uses a vector of shared_ptr's to my signals. I've been able to successfully create and add callbacks to the list,…
BTR
  • 4,880
  • 4
  • 24
  • 21
1
vote
1 answer

boost::function assignment to member function

I want to use a boost::function and pass it to a function to function as a callback. I seem to be having some trouble assigning the member function to it. The function that I want to pass it to is a static function (as it is invoked on another…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
1
vote
3 answers

boost::function and multiple argument member-function

I have the following definition of a boost::function object: typedef boost::function concat; I am passing this function as a struct constructor argument: struct add_node_value_visitor :…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
1
vote
1 answer

Passing a member function as a callback, boost::bind, boost::function

I stumbled upon a curiosity, when investigating the possibility of passing member functions as callbacks using boost::bind and boost::function. I was fooling around with a model of two classes. The first one (Organism) exposes its member variable…
audio
  • 314
  • 4
  • 12
1
vote
2 answers

Invoking a boost::function through boost::function_base

I have an unordered_map of functions that should be called on an object when an XML file is parsed. I have found that boost::function has a base class named boost::function_base, however as expected I cannot invoke it because I don't have the…
the_drow
  • 18,571
  • 25
  • 126
  • 193
1
vote
1 answer

How to use boost::bind to bind a member-function to ANY object

I'm trying to achieve something with boost::bind boost::function but can't make it work. I see how to bind a member function of an object with some arguments to be used later as a void/void function. But how to bind it to any object. I'd like to…
jpo38
  • 20,821
  • 10
  • 70
  • 151
1
vote
1 answer

automatic conversion from boost::bind_t to boost::function

I have a method of the following signature: template void register_msg_action(const pmt::pmt_t& name, boost::function converter, boost::function action) (pmt_t is a complete type, before you ask) as…
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94