Questions tagged [stdbind]

The C++11 function std::bind() fixes some or all arguments of a function object, returning another function object that takes fewer arguments.

std::bind performs Partial Function Application of arbitrary C++ function objects, fixing some or all arguments of a function object and returning another function object that takes fewer arguments.

The function is based on boost::bind() which originated in the library (see ) and an earlier version was included in as std::tr1::bind().

371 questions
1
vote
2 answers

How do pass arguments to boost asio async_accept

I have one problem. I'm developing chat server, using boost::asio. and Here, void CServerSocket::StartAccept(boost::asio::ip::tcp::acceptor &acceptor) { std::shared_ptr socket(new…
BombPenguin
  • 211
  • 2
  • 3
  • 10
1
vote
2 answers

Crash when calling std::function from std::vector c++

When I do this I get this error Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared…
DogDog
  • 4,820
  • 12
  • 44
  • 66
1
vote
1 answer

return type of std::bind implicitly convertible to two different explicit constructors

Given two explicit constructor overloads (based on different std::function<...> types), the return value of std::bind is able to select either (thereby making the call ambiguous) call of overloaded ‘Bar(std::_Bind_helper
Steve Lorimer
  • 27,059
  • 17
  • 118
  • 213
1
vote
3 answers

C++ std::bind accept typename as first argument

I have encountered some strange behavior. This code gives me errors: struct Game { void stop() {std::cout << "success\n";} }; template struct holder { std::map> funcMap; template…
Astrognome
  • 303
  • 3
  • 9
1
vote
2 answers

std::function with unique_ptr argument

Given a function like void MyFunction(std::unique_ptr arg); it is not possible (MSVC 2012) to create a functor like std::function)> f = std::bind(&MyFunction, std::placeholders::_1); The problem is not the bind -…
Zero
  • 11,593
  • 9
  • 52
  • 70
1
vote
1 answer

Binding with boost works while with std doesnt, whats the diffrence?

I tried to bind a function with std::bind, it kept saying that there is no overload for my set of arguments. It worked with boost::bind. Whats the diffrence between std and boost bind? Im using: Microsoft Visual Studio Ultimate 2012 Version…
Marcin Król
  • 1,555
  • 2
  • 16
  • 31
1
vote
1 answer

How to avoid explicit cast with std::bind() temporary objects?

The return type of std::bind is (intentionally) unspecified. It is storable in a std::function. The example program below shows how I have to explicitly cast the temporary object returned by std::bind() to a std::function in order to call fn1(). If…
Scott Smedley
  • 1,779
  • 20
  • 28
1
vote
2 answers

Auto type inference with functor does not work

Possible Duplicate: std::bind a bound function void foo0(int val) { std::cout << "val " << val << "\n"; } void foo1(int val, std::function ftor) { ftor(val); } void foo2(int val, std::function ftor) { ftor(val); } int…
Simon1X
  • 101
  • 9
0
votes
1 answer

Bind and pass around templated function calls

This doesn't work: http://ideone.com/mUL5Y Figured I helped it a little with deducting that type: http://ideone.com/mGfUj Doesn't work either! I don't understand why not. How should I do this?
Nick
  • 2,662
  • 2
  • 25
  • 48
0
votes
2 answers

How to use std::bind to correctly setup mosquitto callbacks on a C++ class member function

I'm doing a MQTT client C++ class using mosquitto: The class declaration (MQTT.hpp): #include #include #include #include #include #include #include #include class…
Mendes
  • 17,489
  • 35
  • 150
  • 263
0
votes
0 answers

Linker error when wrapping a call to std::bind

I am trying to save callbacks for later use in a class and run into the problem that the linker apparently can't see all the symbols it needs. The callbacks are member-functions of another object. If i hand a std::function over to the method…
0
votes
0 answers

Wrapping templated register callback function

I'm trying to wrap a register callback function from ros2 message_filters synchronizer and running into some issues. The idea is to have a pure virtual interface and 2 derived classes, both will have a function called registerCallback; the first…
0
votes
0 answers

Extern random distribution in C++ with std::bind causes declaration error

I have a c++ project with several classes, which all require rng. For this purpose I use the following bit of code, in a header that all classes include. Random.h : #include #include std::default_random_engine…
Yeb02
  • 21
  • 4
0
votes
1 answer

Is it possible to bind a function from a vector of objects to a std::function, or how would you access a function from a vector of objects this way

I have a two classes, one of which is a 'main' configuration, the other is a secondary configuration with a subset of some options from the main configuration. One of the 'main' configuration members is a vector of secondary configuration objects…
Douglas B
  • 585
  • 2
  • 13
0
votes
1 answer

creating a std::bind to bind a class method within itself

I'd like to be able to bind a function with set parameters within itself - I've been given an implementation of scheduled callbacks wherein there's a multimap from std::chrono time signatures to std::function, and I want to have this…
DSiegmeyer
  • 17
  • 3