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 to create a thread by a child member function

I have a IBase class and a Child class. I need to call different proc function in different child class. I'm not sure which form below is actually right, maybe neither XD. Form 1: Exactly I don't want my IBase have any non-virtual function. Form 2:…
StephanXu
  • 49
  • 5
1
vote
1 answer

std::bind troubles with cv::face::FN_FaceDetector

I'm writing a class that basically wraps the cv::face::FacemarkLBF OpenCV class for face detection and facial landmark detection. As part of this effort, I wrote my own face detector function, which is a class member since it uses parameters that…
acr
  • 97
  • 6
1
vote
0 answers

Run class member function in separate thread

Good time of the day! I'm using Visual Studio 2015 with boost 1.66. Currently, I'm trying to run class member function in a separate thread using boost. void ServerWorkerTh() { } void StartServer() const { auto f =…
user922871
  • 435
  • 2
  • 6
  • 17
1
vote
1 answer

std::bind: error: too few arguments to function call, single argument was not specified

I have the following code: void MyClass::create_msg(MyTime timestamp) { // do things here ... } and I tried to create a std::bind for the above function: MyMsg MyClass::getResult(MyTime timestamp) { // do things here ... …
Edamame
  • 23,718
  • 73
  • 186
  • 320
1
vote
1 answer

std::bind and variadic template function

Is this even possible? #include #include enum class Enum {a, b, c }; class Dispatch { public: void check(uint16_t) { std::cout << "check 16\n"; } void check(uint32_t) { std::cout << "check 32\n"; } void…
user1715587
  • 155
  • 1
  • 10
1
vote
2 answers

No suitable conversion user-defined conversion with std::bind()

I'm trying to implement a Button class which invokes a callback when the button is clicked. class Button { public: void SetOnMouseClickCallback(std::function f); // Some other stuff private: std::function
Pvt.Derpy
  • 13
  • 3
1
vote
1 answer

C++ socketio segmentation fault in bound function

This is my first question on stackoverflow and I'm new to C++. I hope you can all forgive my ignorance to the probably obvious problem here, but I'm at a loss. Basically, I'm just trying to catch events emitted by a nodejs server in my C++ client.…
Roni Peled
  • 38
  • 4
1
vote
1 answer

How to pass a member function as callback param to a function that expects a `typedef-ed` free function pointer?

// typedef from library that I cannot change typedef int (*mg_request_handler)(mg_connection *conn, void *cbdata); // this free function is for testing int get_handler_free(struct mg_connection* conn, void* cbdata) { //... } // this member…
duong_dajgja
  • 4,196
  • 1
  • 38
  • 65
1
vote
1 answer

execution order of functors in std::bind() parameter list (maybe not related to evaluation order of function parameter)

I was just wondering and write the following code: (I am not asking for work arounds, I just want to know whether bind() handles this perfectly or not). Besides, I think bind can handle this and define an order for it, but I am not sure or maybe it…
Han XIAO
  • 1,148
  • 9
  • 20
1
vote
1 answer

UML class diagram's <> vs std::bind()

Between two certain repos I've so far used an interface class (with inheritance), and this I've recently replaced with a callback function using std::function() & std::bind(). Using the old, interface-like method I ended up with…
janos_dfc
  • 87
  • 1
  • 5
1
vote
1 answer

Why won't std::bind compile when bound to a member function?

I am currently working on a program that needs to use std::bind to bind arguments to a member function, but when I attempt to do so, I get a compiler error. The following is a minimum example: Map.h: #pragma once class Map { void…
john01dav
  • 1,842
  • 1
  • 21
  • 40
1
vote
0 answers

CYTHON, How can i pass a member function as a callback to native

I am able to get normal callbacks from native to Cython. But, how do i set a member function to be callback in cython. My sampleCallback.h file is : namespace mango { class sampleCalls { public: typedef void (*Callback)(char *name); …
wolv3r1n3
  • 63
  • 6
1
vote
2 answers

C++ binding callbacks to a class

I am registering callbacks to a hash map in a class to handle various 'events', so I am using std::functionto store them in the hash map I want the callbacks to be bound to the class so they can access some common methods, so I am using std::bind to…
jramm
  • 6,415
  • 4
  • 34
  • 73
1
vote
1 answer

Should std::bind require move constructor?

When I try the following code in GCC 6.3 (ideone.com), it compiles and prints "OK!". When I try the same code in C++ Builder 10.1, it fails to compile: [bcc32c Error] tuple(110): no matching constructor for initialization of 'A' tuple(433): in…
VLL
  • 9,634
  • 1
  • 29
  • 54
1
vote
1 answer

Std bind equivalent to lambda for binding a member function to a std function

I can bind a private member function using a lambda. I'm struggling to write the equivalent using std::bind. This is my attempt, but it doesn't compile. #include class A { private: double foo(double x, double y); …
Blasco
  • 1,607
  • 16
  • 30