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

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 simplified problem : #include…
jinc
  • 1
  • 2
0
votes
0 answers

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 following the advice on this post to extract…
Sid
  • 266
  • 5
  • 13
0
votes
1 answer

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 #include template void…
rahman
  • 4,820
  • 16
  • 52
  • 86
0
votes
1 answer

boost bind template error

//error C2784: 'HRESULT get_wrapper(T *,boost::function)' : //could not deduce template argument for 'boost::function' //from 'boost::_bi::bind_t' STDMETHODIMP CAttributeValue::get_Name(BSTR* pVal) { return…
Dustin Getz
  • 21,282
  • 15
  • 82
  • 131
0
votes
0 answers

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(boost::protect(boost::bind(&ItemHandler::writer,…
Naga
  • 487
  • 2
  • 7
  • 23
0
votes
0 answers

Segmentation fault when using OpenMP for_each and BOOST_FOREACH

I searched a lot on a parallelized version of for_each in C++. I found the following piece of code regarding paralleling for_each from here: template void parallel_for_each(std::vector< T> & obj, Function f) { int size =…
H'H
  • 1,638
  • 1
  • 15
  • 39
0
votes
0 answers

How to assign member function pointer to non-member function pointer?

How to assign member function pointer to non-member function pointer? I have this library API function: int pfring_loop(pfring *ring, pfringProcesssPacket looper, const u_char *user_bytes, u_int8_t wait_for_packet); API defined function…
Bryan Fok
  • 3,277
  • 2
  • 31
  • 59
0
votes
2 answers

Boost Bind to Method

I'm trying to use boost thread to multi-thread one of my applications. The part I have an issue with is the boost::bind. Here is what I am trying to do : boost::bind(&Class::CalculateRT(i, i - 1), RT)); Considering : RT is a TransformType…
Zepherus
  • 51
  • 9
0
votes
1 answer

Using both boost::bind and std::tr1::bind in different parts of the client code

I am using two custom libraries that use the bind functionality. One of them uses the bind functionality present in std::tr1 while the other uses boost bind Now the problem is with respect to the placeholders. Since boost bind's placeholders are in…
rgk
  • 858
  • 16
  • 28
0
votes
1 answer

boost::bind seems to produce different symbols with different compilers?

I have a shared object library which uses templates and callbacks. I needed to port it to another system which uses an older version of g++ (4.1.2). This is pseudo code of what I'm doing: shrdPtr.reset( new…
don_q
  • 415
  • 3
  • 11
0
votes
1 answer

boost::bind to class member with null object reference

Take the following example class foo { public: foo() { cout << "foo has been constructed" << endl; } ~foo() {}; void DoSomething( int i ) { cout << "integer = " << i << endl; } }; int main() { auto b = boost::bind(…
tuskcode
  • 317
  • 2
  • 14
0
votes
1 answer

Binding a member signal to a function

This line of code compiles correctly without a problem: boost::bind(boost::ref(connected_), boost::dynamic_pointer_cast >(shared_from_this()), boost::asio::placeholders::error); However when assigning it…
the_drow
  • 18,571
  • 25
  • 126
  • 193
0
votes
1 answer

Compilation failure when using std::shared_ptr instead of boost::shared_ptr

The code below successfully sends an async message to the given endpoint. // message is a boost::shared_ptr // open a UDP socket boost::asio::ip::udp::socket socket(ioService); socket.open(boost::asio::ip::udp::v4()); // create the…
ksl
  • 4,519
  • 11
  • 65
  • 106
0
votes
1 answer

bind binded function as argument

I have a class foo with a method bar which takes something callable (function-pointer/ functor). this callable something should be passed to another method doit as an binded element with a third method bar_cb method. #include #include…
user1810087
  • 5,146
  • 1
  • 41
  • 76
0
votes
1 answer

errors using boost::function with boost::bind with boost::asio

i am facing problems combining boost::function with boost::bind and boost::asio. i am facing snippets of code down, the compiler throws tons of errors, i am pasting the root errors. static void startAccept(boost::asio::io_service &io, …
Ravikumar Tulugu
  • 1,702
  • 2
  • 18
  • 40