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

What is the correct way to reuse the return value of a boost::bind call?

I have to following code: class Timer; typedef boost::signals2::signal signal_type; void Timer::create(long expiration, signal_type::slot_type const& slot); The normal usage of that is to call, timer.create(2000,…
Carlo Wood
  • 5,648
  • 2
  • 35
  • 47
0
votes
2 answers

Boost bind and assign to convert vector to a string

Suppose I have the following containers: vector input = assign::list_of("one")("two")("three")("four"); vector > result; And say I want result to look something like: {{"one", 1}, {"two", 1}, {"three", 1}, {"four", 1}} I…
Tom
  • 6,601
  • 12
  • 40
  • 48
0
votes
1 answer

Macro to improve callback registration readability

I'm trying to write a macro to make a specific usage of callbacks in C++ easier. All my callbacks are member functions and will take this as first argument and a second one whose type inherits from a common base class. The usual way to go…
Warren Seine
  • 2,311
  • 2
  • 25
  • 38
0
votes
2 answers

binding to boost::function class member compilation error

boost::function test_func; struct test_t { boost::function foo_; void test() { // This works as expected test_func = boost::bind(test_t::foo_, 1); } }; int main(int argc, _TCHAR* argv[]) { test_t…
7.62
  • 3
  • 1
0
votes
1 answer

cannot call member function without object for vector of shared_ptr of object

#include //#include #include #include #include #include using namespace std; using namespace boost::lambda; class Base { …
DeltaVega
  • 75
  • 1
  • 8
0
votes
1 answer

boost::bind arguments of static function

I try to bind boost::asio arguments. Function to bind is static member of structure: template struct bind_struct{ typedef boost::system::error_code error_code; typedef boost::asio::ip::tcp::acceptor …
crastinus
  • 133
  • 2
  • 10
0
votes
1 answer

function with function object argument of different signatures

I tried overloading a function with boost::function with different signatures, it did not work. I tried using template Connection *connect(boost::function f) which also failed because boost::bind doesn't implicitly convert that…
Saif Ur Rehman
  • 338
  • 3
  • 14
0
votes
1 answer

unresolved overload with bind and make_pair

I am trying to copy all of the keys of a map into another by using std::for_each and boost::bind. I am getting compile error saying error: no matching function for call to ‘bind(, boost::arg<1>&,…
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
0
votes
2 answers

Binding function with more arguments than needed and passing definite arguments to it

Let I have a function void f1(type_a a, type_b b, type_c c) I want to convert it to void f2(type_a a, type_b b) where instead of c will be passed my object. How can I do this usind boost:bind?
w00drow
  • 468
  • 2
  • 11
0
votes
1 answer

Passing boost.coroutine through function arguments

Well, my problem is to properly pass boost::coroutines::coroutine object as function argument. I can't do that by reference because calling this method is realized by boost::bind and boost::asio (there is a possibility that this…
Piwosz
  • 21
  • 3
0
votes
1 answer

storing the output of boost::bind in a boost::function

I currently have something like this void asomeMethod(int q) { std::cout << "Method with parameter " << q ; } int main() { boost::function parfunct; parfunct = boost::bind(&asomeMethod,12); parfunct; //Does not call…
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
0
votes
1 answer

boost::bind to class member function

I'm trying to pass member function wrapped to stand-alone function via boost::bind. The following is the reduced sample. // Foo.h typedef const std::pair (*DoubleGetter)(const std::string &); class Foo : private boost::noncopyable…
Loom
  • 9,768
  • 22
  • 60
  • 112
0
votes
1 answer

How to pass class/structure instances as arguments to callbacks using boost::bind?

I am looking for and stuck on issue of passing class and structure instances as arguments to call back functions using boost::bind So far call back using this method works fine. I want to use shown below code snippets class A { public : static…
Kyaw
  • 1
0
votes
1 answer

Compile error with boost bind in std::find_if

Consider this snippet: #include #include #include #include template class SomeClass { public: SomeClass() : m_pred(boost::bind(&SomeClass::someMethodA, this,…
Juergen
  • 3,489
  • 6
  • 35
  • 59
0
votes
1 answer

boost::bind() a member function to boost::function with object pointer as placeholder?

I am using boost v1.37 on MSVC7. I'm stuck on these old versions and cannot upgrade so please help me work within my means here and do not suggest upgrades as an answer. I have a class with three member functions. I want to define a boost::function…
void.pointer
  • 24,859
  • 31
  • 132
  • 243