Questions tagged [boost-bind]

boost::bind is a generalization of the standard C++ functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions.

boost::bind is a generalization of the standard C++ functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions. bind does not place any requirements on the function object; in particular, it does not need the result_type, first_argument_type and second_argument_type standard typedefs.

boost::bind was proposed for standardization and a version of it was included in as std::tr1::bind and an improved version is included in the standard as std::bind (see ).

352 questions
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

boost::bind member function as argument inside its own member function

I am following a tutorial (https://www.gamedev.net/blogs/entry/2249317-a-guide-to-getting-started-with-boostasio/) for boost asio. Now I want to convert some of the aspects of this tutorial to a class, to learn more about what actually goes on…
1
vote
3 answers

c++: Can boost::bind be used to convert member function to expected function pointer signature?

I'm using a 3rd party library that passes function pointers to a method call. class RTSPClient{ public: ... typedef void (responseHandler)(RTSPClient* rtspClient, int resultCode, char* resultString); ... unsigned…
Ralf
  • 9,405
  • 2
  • 28
  • 46
1
vote
1 answer

boost::bind as an argument to accept function with n args and use the same on further function calls

Can i do something like below ? Is it possible or is there any workaround? .. PostWorkToThread( boost::bind(func_x, arg1) ); PostWorkToThread( boost::bind(func_y, arg1, arg2) ); PostWorkToThread( boost::bind(func_z, arg1, arg2, arg3) ); .. void…
Maha
  • 11
  • 5
1
vote
0 answers

Storing a complete generic function call for playback later?

At the moment I am storing a function call via the function MyClass::Enable that I've presented below. It's generic in the sense that I can later play the function back on a consumer thread by looping through the commanList and not have to provide…
Sent1nel
  • 509
  • 1
  • 7
  • 21
1
vote
1 answer

Token parser semantic action

I have written a working token parser based on the code shown at spirit lex example 4 One of my rules looks like this set_name = ( tok.set_ >> tok.name_ >> tok.identifier ) [ std::cout << val("set name…
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
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

boost bind with member function in asio spawn call

in the following code i make map, then add some httprequest class instances to it, then i call boost asio spawn using member function of httprequest class, i asked about this before and told it was duplicate , so i read the post and made some…
ahmed allam
  • 377
  • 2
  • 15
1
vote
0 answers

How to use boost bind with member function nested in class with reference parameter?

I tried to use boost::bind inside a class method, which in turn calls another class method with reference parameter: void some_method() { for_each( con.begin(), con.end(), boost::bind( &comb_str::dfs, this, _1 ) ); } void dfs( string& str )…
roxrook
  • 13,511
  • 40
  • 107
  • 156
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

Functor for applying an arbitrary member function to a container of containers of objects

We're transitioning to C++11 but still a few months away. Please feel free to give C++11 responses, but we're curious whether there's a non-ugly way to do it in C++98/03. A co-worker came to me with code resembling: typedef…
Brian Vandenberg
  • 4,011
  • 2
  • 37
  • 53
1
vote
1 answer

concatenate values in a while loop gone wrong

I have a boost::variant, which contains various types and I have a string which needs to look like this: type=D,S. The values in the variant are D and S respectively, the key is 'type'. It is a map > where I'm now…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
1
vote
2 answers

Why Is my implementation of io_service::run_one() causing an indefinite block and triggering error #125?

I am using BOOST for asynchronous communication with a serial port. I can't pinpoint the cause of the error I am facing and would appreciate some guidance. std::string myclass::readStringUntil(const std::string& delim) { …
Ryan Lee
  • 361
  • 1
  • 3
  • 10
1
vote
1 answer

boost phoenix bind a semantic action with multiple parameter and a return value

I'm new to both C++ and Boost spirit. I'm stuck on this for a day now. I want to parse two strings separated by a dot. basically, I need following strings to be parsed to an integer. eg: [field] --> integer // working eg2:…
udakarajd
  • 114
  • 11
1
vote
1 answer

Usage of boost::bind ... what am I doing wrong

I have adapted the code from the following question's first answer for making a periodic timer: How do I make the boost/asio library repeat a timer? I removed the "count" variable as the method I want to repeatedly execute doesn't take any…
dfsg76
  • 504
  • 1
  • 6
  • 22