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

Is it possible to attach an action to a boost::spirit::rule parser which assigns the parsed result to a member of a (yet) unknown instance?

I'm trying to reference a member of a (yet) unknown instance from within a boost::spirit rule definitions' action, so in pseudocode, instead of double_[ref(rN) = _1] I'm looking for something like X** ppx; double_[ref(&X::rN, ppx) =…
3
votes
2 answers

boost::bind does not compile

I am new to boost spirit and I have the following problem: #include #include #include #include #include #include…
frank
  • 481
  • 8
  • 16
3
votes
1 answer

redirecting boost bind

Is the following conversion possible? I've tried boost::lambda and just a plain bind, but I'm struggling to make the conversion in-place without a special helper class that would process foo and invoke bar. struct Foo {}; // untouchable struct Bar…
3
votes
1 answer

Can I use boost::bind() with mem_fun_ref()?

My question is pretty straightforward: can I do something like this? Say class foo contains the following member function: foo foo::DoSomething(input_type1 input1, input_type2 input2) { ... // Adjust private datamembers return…
Wouter
  • 161
  • 1
  • 6
3
votes
1 answer

Trouble with using boost::bind & boost::function

Following on from this question How to pass class member functions to a method in a 3rd party library? Quick recap is I need to pass pointers to functions to the constructor of a class called moveset in a 3rd party library with the definition…
oracle3001
  • 1,090
  • 19
  • 31
2
votes
1 answer

Is there a QPointer specialization for boost::bind

boost::bind handles boost::shared_ptr the same way as raw pointers. QObject * object(new QObject); boost::shared_ptr sharedObject(new QObject); bind(&QObject::setObjectName, object, _1)( "name" ); bind(&QObject::setObjectName,…
TimW
  • 8,351
  • 1
  • 29
  • 33
2
votes
2 answers

boost::bind with maps, what's the difference between binding std::pair and std::map::value_type?

What's the difference between the following two cases? std::pair example_1 (std::make_pair (1,"foo")); int value_1 = boost::bind (&std::pair::first,_1) (example_1); std::map::value_type example_2…
user1192525
  • 657
  • 4
  • 20
2
votes
1 answer

boost::bind composition inside io_service::post function

Given the following class class task_counter { …
fremmi
  • 33
  • 4
2
votes
1 answer

Retrieve pointer to best match from overload set without calling

For various reasons I need to use 2 phase construction, furthermore the last phase is deferred and performed by another thread, some context: ... #define BOOST_PP_LOCAL_MACRO(n) \ template < typename ConnectionType, BOOST_PP_ENUM_PARAMS(n,…
Ylisar
  • 4,293
  • 21
  • 27
2
votes
1 answer

How to use Boost::asio::buffer(buf, size) with boost bind?

We have a member function in some .h file template int read_some(boost::asio::ip::tcp::socket& sock, const MutableBufferSequence& buffers) { return sock.read_some(buffers); } And such code we want to have…
Rella
  • 65,003
  • 109
  • 363
  • 636
2
votes
2 answers

Boost function and boost bind: Bind the return value?

This is related to this previous question: Using boost::bind with boost::function: retrieve binded variable type. I can bind a function like this: in .h: class MyClass { void foo(int a); void bar(); void execute(char* param); int…
Smash
  • 3,722
  • 4
  • 34
  • 54
2
votes
3 answers

Call AfxBeginThread with class member function?

How can I call AfxBeginThread with an arbitrary non-static class method? Maybe there is something I can do with boost bind? Below is the expected usage from Microsoft (and is an example of calling a non-static method but it is hard-coded which…
User
  • 62,498
  • 72
  • 186
  • 247
2
votes
1 answer

Using std::vector with boost::bind

While trying to get comfortable with boost, stumbled into problem with using boost::function along with std::vector. I'm trying to do a simple thing: have a list of functions with similair signatures and then use all that functions with…
elricbk
  • 107
  • 7
2
votes
1 answer

Expressing Church Numerals with Boost.Bind

Church numerals can be expressed in C++0x (C++11?) using the new lambda parts of the language using something like this: typedef function F; static const F id = [=](int x) { return x; }; function church(unsigned int i) { if(i ==…
PaulH
  • 7,759
  • 8
  • 66
  • 143
2
votes
2 answers

Binding the parameters before setting the function pointer?

I would like to try something out and unify some boilerplate code in one of our dynamic library API wrappers. Essentially, I would like to do the following: typedef bool (*MyFPtrT)(long id, std::string const& name); typedef boost::function
Martin Ba
  • 37,187
  • 33
  • 183
  • 337