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

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 < double > dist_err; // ... do something with…
Bojian Zheng
  • 2,167
  • 3
  • 13
  • 17
1
vote
2 answers

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: class Example { public: typedef ... Callback; …
Colin Andrews
  • 191
  • 11
1
vote
1 answer

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 "&Element::Fn". Here is a similar piece of code: typedef…
H'H
  • 1,638
  • 1
  • 15
  • 39
1
vote
1 answer

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 #include #include #include #include void test() { …
lars
  • 475
  • 2
  • 6
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
1
vote
1 answer

Boost.Bind'ing a member function and posting it to io_service

I am trying to wrap an object that represents a job to be done by an io_service. The job is of arbitrary type, and does not have to be an IO operation. Similar to what is described here. I have been able to post bound regular functions, but was not…
feeling_lonely
  • 6,665
  • 4
  • 27
  • 53
1
vote
2 answers

boost:bind and io_service in two different classes

I am kind'a new to Boost. I would like to know how to construct an io_service in one class and send it tasks from another class. My problem is BOOST_ASIO_COMPLETION_HANDLER_CHECK complains and wont let the code compile. He is a skeleton of my…
feeling_lonely
  • 6,665
  • 4
  • 27
  • 53
1
vote
2 answers

Shortening boost::function

When passing a boost::function as a parameter to another function (callback), this function's signature can become quite long. Example: Consider this boost::function: boost::function
gpalex
  • 826
  • 1
  • 11
  • 27
1
vote
1 answer

C++ question: boost::bind receive other boost::bind

I want to make this code work properly, what should I do? giving this error on the last line. what am I doing wrong? i know boost::bind need a type but i'm not getting. help class A { public: template void bindA(Handle h) …
Bruno Romano
  • 303
  • 2
  • 10
1
vote
2 answers

boost doesn't bind to member function even using this

I am trying to use boost::bind with a boost::function using this. It seems a trivial example but I cannot make it work. Can you help me? Is it because it is not allowed or am I doing something wrong? // .h class MyClass{ publc: void DoSomething(…
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
1
vote
3 answers

Using boost::bind but allowing any additional parameters to be passed through

I am putting together a "simple" template class. It offers an interface for performing some operations on a database, so there are other members as well (primarily for operating on the container member). However, for our purposes, the template class…
caps
  • 1,225
  • 14
  • 24
1
vote
2 answers

boost lambda::bind return type selection

I would like to call a member through lambda::bind. Unfortunately I have got two members with the same name but different return types. Is there a way to help the lambda::bind to deduce the right return type for a member function call? (bind works…
psaghelyi
  • 500
  • 4
  • 12
1
vote
3 answers

Copy vector of values to vector of pairs in one line

I have the following types: struct X { int x; X( int val ) : x(val) {} }; struct X2 { int x2; X2() : x2() {} }; typedef std::pair pair_t; typedef std::vector pairs_vec_t; typedef std::vector X_vec_t; I need to…
Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
1
vote
1 answer

How to use/manipulate return value from nested boost::bind

I have two functions: 1. A & DataSource(); 2. void DataConsumer( A * ); What I want to achieve: Using one statement to assemble them into one functor. I have tried: 1. boost::function< void()> func( boost::bind( DataConsumer, & boost::bind(…
JQ.
  • 678
  • 7
  • 17