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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
90 views

"No Matching for Call to" and "Template Argument Deduction/Substitution Failed" Error in Boost::bind (C++)

I am a complete beginner in using Boost, and I would like to multithread a certain function defined as (I have been following this thread in defining this function), void function(size_t thread, ...
magus_e's user avatar
  • 31
1 vote
1 answer
922 views

C++ and boost 1.71 - error: reference to ‘_1’ is ambiguous

I am using the libraries websocketcpp and boost 1.71. The code used to work with boost 1.58 but after upgrading both libraries, it won't compile. The C++ compiler is g++ (Ubuntu 9.3.0-17ubuntu1~20.04) ...
grouser's user avatar
  • 618
1 vote
1 answer
210 views

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,...
Lyingdutchman's user avatar
0 votes
1 answer
751 views

How to bind parameter with Boost asio io_context post?

I am trying to post data to io_context, if I bind post with newdata method (with no parameter) it get called, however if I pass any parameter it failed to call newdata method. std::shared_ptr< ...
rahul's user avatar
  • 59
5 votes
1 answer
690 views

Boost bind and 'result_type': is not a member, c++03-friendly

The latest 16.6 update to Visual Studio 2019 removed std::plus::result_type, std::minus::result_type, and related typedefs. (They're deprecated in C++17 and removed in C++20.) A greatly simplified ...
MaddHatter's user avatar
0 votes
0 answers
450 views

i have error its meaning :Error C2440 'return': cannot convert from 'void (__cdecl &)(yield_context)' to 'void (&)(yield_context)'

I am making program in which i try to make boost packaged_task then take its future in vector and launch it with asio post. when i try to make packaged_task ,it gives me this error: Error C2440 ...
ahmed allam's user avatar
0 votes
0 answers
404 views

how to connect a member function to a boost signal

Is there a way to avoid the use of boost::bind to attach a member function to a boost::signal slot? The only way I can get it to work is to use bind like this: mysignal.connect(boost::bind(&...
Jimbo's user avatar
  • 85
0 votes
1 answer
26 views

Pass a std::function as template parameter to another function does not compile

I develop in C+03 using Boost. I would like to bind a function class member. Then pass this to a generic wrapper as template parameter and inside the wrapper to call the real function . But I cannot ...
getsoubl's user avatar
  • 808
0 votes
2 answers
110 views

How does boost::bind pass arguments in C++?

I'm having trouble understanding some parts of these lines of code: fn_ = boost::bind(&CheckFeasibility, this, &world_, _1, _2, _3 ); if (robot_state_->setFromIK(arg1, arg2, arg3, arg4, ...
bbaalleerr22's user avatar
1 vote
1 answer
29 views

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( ...
Maha's user avatar
  • 11
0 votes
1 answer
1k views

Error: No match for call to 'boost::.......'

I am trying to modify another code. Just wanted to add another subscriber to it. This is the skeleton of the code: namespace my_server { a_server::a_server(ros::NodeHandle n) : nh() { ...
UsamaMaq's user avatar
2 votes
1 answer
2k views

invalid use of non-static member function when using boost bind - c++

I'm trying to generate a periodic timer class using the boost.asio library. However, I get "invalid use of non-static member function" errors. The cpp file is as the following: #include "TimerBoost.h"...
Anıl Çavuşoğlu's user avatar
0 votes
1 answer
188 views

Generalize the argument passed to boost::bind

I am trying to write a generic struct MyCounter which uses boost::bind . What I am trying to do is to write MyCounter such a way that by changing its template argument type, I could bind to different ...
rahman's user avatar
  • 4,820
2 votes
2 answers
264 views

Can I store bound functions in a container?

Consider the following code: void func_0() { std::cout << "Zero parameter function" << std::endl; } void func_1(int i) { std::cout << "One parameter function [" << i &...
Sharath's user avatar
  • 1,627
-1 votes
1 answer
159 views

max size of buffer of boost::bind function

i have a question about maximum size of buffer in handler function which is called in boost::bind method. I have a tcp socket client: chat_client(boost::asio::io_service& io_service, tcp::...
nguyen andrew's user avatar
0 votes
2 answers
2k views

How to append parameter using boost::bind?

I'm trying to append another parameter to a ROS subscriber callback function using boost::bind, but I can't figure what is wrong with my code: This is the callback function signature: void ...
Vitor's user avatar
  • 2,734
1 vote
1 answer
426 views

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 ...
ahmed allam's user avatar
0 votes
2 answers
108 views

Is a functor returned by boost::bind with only bound arguments equivalent to a function that takes no arguments?

Suppose an API requests, that a function f must have the signature void function(). Does the following code sample satisfy this requirements? void func(int i) { do_something(i); } int ...
reedts's user avatar
  • 143
4 votes
2 answers
1k views

C++ generic factory with multiple constructor signatures?

Has anyone ever combined the classic generic factory by Andrei Alexandrescu (page 208 of Chapter 8 in Modern C++ Design) with the 'multifunction' capabilities of Boost.TypeErasure? That is, the ...
Jeremy W. Murphy's user avatar
0 votes
1 answer
272 views

Binding callback to a templated object

I have a templated class that holds a callback, stored as a std::function typedef std::function<void()> func_t; template<typename T> struct A { T someMember; func_t callback; }; ...
kebs's user avatar
  • 6,417
0 votes
1 answer
1k views

Using boost:bind to bind a std::function

I have a problem using boost::bind with a function stored into std::function. This is related to boost::asio: I am building a basic UDP server. So, first lets see some code that compiles fine without ...
kebs's user avatar
  • 6,417
1 vote
1 answer
100 views

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 ...
Brian Vandenberg's user avatar
3 votes
1 answer
7k views

Error using boost::bind for subscribe callback

We're getting this compile error followed by many more errors showing attempts to match the subscribe parameters to all possible candidate functions when using boost::bind as a callback for subscribe. ...
Sagar Mohan's user avatar
0 votes
1 answer
45 views

How to understand this boost::bind sentence? It's different from what I searched on Internet

DepthFilter::callback_t depth_filter_cb = boost::bind(&MapPointCandidates::newCandidatePoint, &map_.point_candidates_, _1, _2); And the binded function defines as this: void ...
user7487638's user avatar
1 vote
2 answers
485 views

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 ...
Ryan Lee's user avatar
  • 361
1 vote
1 answer
642 views

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] ...
udakarajd's user avatar
  • 114
1 vote
1 answer
979 views

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 ...
dfsg76's user avatar
  • 504
0 votes
1 answer
296 views

How can I boost::bind to a member of a managed class which passes and returns a std::string?

I'm trying to do something very similar to this but I'm struggling to pass the string to/from the callback. This is a pared down version of the code I'm trying to run: using namespace System; using ...
Jon Cage's user avatar
  • 36.4k
0 votes
2 answers
100 views

Can I use boost::bind to store an unrelated object?

Can I use boost::bind to make the resulting function object store an object which is not declared as argument to the bound target function? For example: void Connect(const error_code& errorCode) {...
shadow_map's user avatar
0 votes
0 answers
161 views

Boost Factory compile error

Trying to implement abstract factory with Boost Factory, classes of the hierarchy have c-tor params, already looked this discussion: Passing arguments in constructor with boost factory My example is ...
user avatar
3 votes
1 answer
1k views

Use of boost coroutine2 without lambdas

I guess this is the first time I couldn't manage to find an already answered question in here, and I could really use some help if anyone have successfully used boost coroutine2 lib without lambdas. ...
Marcio Mutti's user avatar
1 vote
1 answer
162 views

boost accumulator_set: expect primary expression

I am a new to Boost library. I want a program that could compute the min, max, mean and variance of a distance vector (of type std::vector < double >) and I wrote the following code std::vector ...
Bojian Zheng's user avatar
  • 2,197
0 votes
1 answer
135 views

Linker errors when using Boost Unique pointer with Boost Bind and Boost Function

Using Boost Bind with a Boost Unique Pointer and Boost Function I am receiving linker errors depending on how I pass a callback to the receiving function. If I create a Boost Function member variable ...
boneill's user avatar
  • 31
0 votes
3 answers
103 views

The most compact way to find an element in container with the minimum value of given field

Let's we need to find an element with the minimum value of given field. #include <boost/range/algorithm/min_element.hpp> #include <vector> struct Item { size_t a; size_t b; }; ...
DmitriyH's user avatar
  • 420
0 votes
0 answers
65 views

Boost spirit semantic actions, boost::bind and Visual Studio 2015

In old version of VisualStudio, I use semantic actions in grammar struct in this mode: boost::bind(&asmGrammar::do_comment, this, qi::_1); // void do_comment(string& s) {/*...*/ } But this ...
Claudio La Rosa's user avatar
2 votes
2 answers
1k views

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 ...
Tyler Jandreau's user avatar
1 vote
2 answers
166 views

How can I make a templated function that takes a parameter that is the result of boost::bind?

I have a helper method that takes as input a boost::function<> type object and wraps the function with another functor that handles some other logistics. Here is what my signature looks like: ...
Colin Andrews's user avatar
4 votes
2 answers
552 views

Applying C++11 move semantics to bound functions

I have some existing C++98 code that makes use of boost::function and boost:bind for asynchronous callbacks. Some relevant simplified fragments of the code include: typedef boost::function<void (...
Miral's user avatar
  • 12.6k
0 votes
1 answer
94 views

What is occurring at this bind in C++?

I know that this is simple code, but I can't find amazingly detailed documentation anywhere for the project or on C++'s bind. This is the code: uri.canonize(bind(&FaceController::...
Bronze's user avatar
  • 153
0 votes
2 answers
412 views

error: call of overloaded ‘bind(int (Class::*)(int, int), Class*, int, int)’ is ambiguous

I'm trying to use boost::bind, could anybody tell me where is wrong in the following code segment? #include <iostream> #include <boost/bind.hpp> using std::cout; using std::endl; class ...
neurobot's user avatar
  • 348
2 votes
1 answer
459 views

Compile error on boost::bind ( member function) in spirit parser action on context argument

I use vc14 and boost version is 1.60. #include <boost/config/warning_disable.hpp> #include <boost\spirit\home\qi.hpp> #include <boost\variant.hpp> #include <boost\spirit\include\...
Marcin Domarski's user avatar
0 votes
0 answers
1k views

"'boost::bind' is ambiguous" C++ error

I'm trying to control an arduino from a c++ program, after some research I found this, but the problem is, it does not compile on eclipse. It gives me 2 errors at line 102 in 3_async>AsyncSerial.cpp ...
4TheGame3's user avatar
0 votes
1 answer
53 views

Passing boost::bind parameters as arguments

I have wrote somo code that works fine. But I would like to write it in another way and I don't know how to do. This is what I have done : class A { public: void doAction(); } typedef boost::...
Nicolas Krieger's user avatar
3 votes
4 answers
1k views

Boost::asio and boost::bind: Functor memory is never released

My code is allocating memory and never freeing it, even though it should (at least in my opinion). The header looks like this: typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ...
Norman's user avatar
  • 73
0 votes
1 answer
259 views

Getting boost::function from boost::lambda::bind of new_ptr with parameters

I am trying to obtains a boost::function to a new_ptr (with parameters) which can be stored in a hash table for later use. A kind of registrar of ids to constructors for modules to use. Below is the ...
jinc's user avatar
  • 1
0 votes
0 answers
261 views

Use of boost libraries apply_visitor, bind and function in C++

I am new to the use of the boost library and have questions regarding its use. I have a vector union of ints and strings generated by use of boost::variant. Assume the vector is called myvec. I tried ...
Sid's user avatar
  • 266
1 vote
1 answer
889 views

Using find_if and boost::bind with a set of shared_pointers

I have a vector of shared_ptr, I want to combine boost shared_ptr and bind together. My question is very similar to this, except that instead of "&MyClass::ReferenceFn" I would like to call "&...
H'H's user avatar
  • 1,648
1 vote
1 answer
392 views

Combination of boost range for_each, bind, copy and a back_inserter fails

I want to copy all the integers contained in a into b. #include <vector> #include <iterator> #include <boost/bind.hpp> #include <boost/range/algorithm/for_each.hpp> #include &...
lars's user avatar
  • 475
0 votes
1 answer
717 views

mismatch in the number of arguments passed to boost function using boost::bind

I am trying to create a Functor using boost function and bind, but i cant pass only a single argument to the destination function which has 3 arguments: #include <boost/bind.hpp> #include <...
rahman's user avatar
  • 4,820
0 votes
0 answers
126 views

boost::bind not working as expected in multi threaded process

The following function is called by multiple threads simultaneously. handlework(ItemWork &itemWork) { ItemHandler *itemHandler = NULL; itemHandler = new ItemHandler (); itemWork.work(...
Naga's user avatar
  • 497

1
2 3 4 5
8