stdbind

    0熱度

    1回答

    我想創建一個模板類,它將反過來生成一個函數的包裝。該類將隨後返回包裝。我想用模板具有將與任何功能的工作與不同的簽名,如普通類: std::function<void()>task = std::bind(fun1, param1, param2); std::function<int(int, int)>task = std::bind(fun2, param1, param2); 我想有這樣的事

    1熱度

    2回答

    我正在使用VC++編譯我的程序(使用Visual Studio 2015,更新3),並且某些代碼段無法編譯。 基本上,我想綁定一個函數,該函數獲取對原子布爾值的引用與原子布爾值。自包含的代碼: void stub(std::atomic_bool& b) { b = true; } int main() { std::atomic_bool b(false);

    0熱度

    2回答

    我無法編譯C++ 11中的簡單程序。 你可以在這裏看看http://cpp.sh/9muxf。 #include <functional> #include <iostream> #include <exception> #include <tuple> #include <map> using namespace std; typedef int Json; typedef s

    1熱度

    1回答

    我有一個包含函數指針列表的類。 這些函數指針指向一個子類,這是必然像這樣的成員函數: functionList.push_back(std::bind(&SubClass::function, this, std::placeholders::_1, std::placeholders::_2)); 現在,複製與functionList類時,函數指針仍指向老班。 如何重新綁定函數指針到新類?

    0熱度

    1回答

    我試圖用std :: function和std :: bind綁定方法時遇到問題。 在我CommunicationService類: this->httpServer->BindGET(std::bind(&CommunicationService::ManageGETRequest, this, std::placeholders::_1)); CommunicationService ::

    2熱度

    1回答

    我一直在試圖編寫一段非常簡單的代碼,但它似乎不工作,我無法從編譯器中做出任何意義錯誤。 代碼: #include <iostream> #include <sstream> #include <functional> class c { public: void test(std::stringstream ss){ std::cout<<ss.str()<<st

    2熱度

    1回答

    昨天我已經實現了一些測試函數,並且所有的編譯和工作都沒有錯誤。今天,我回到我的電腦,我的std::bind的下劃線是紅色的,但編譯沒有錯誤。看起來像Intellisense和編譯器不同意std::bind類型。我怎樣才能解決這個問題? #include <functional> class MyClass { public: int doE() { return 0;

    0熱度

    1回答

    我需要將一個參數綁定到類成員函數。 事情是這樣的: #include <functional> #include <iostream> struct test { void func(int a, int b) { std::cout << a << " " << b << std::endl; } }; int main(int argc,

    1熱度

    2回答

    我的問題是我在下面指出ERROR的那一行給出錯誤,因爲std :: thread構造函數計算出要調用的函數並且需要函數簽名所需的參數 。 有什麼辦法解決這個問題嗎?如果我試圖解碼來自packaged_task的函數名稱和參數列表,那麼我無法使用get_future函數來打包任務,並且需要添加我自己的承諾/將來的代碼來處理這個問題。 #include<iostream> #include<stri

    1熱度

    1回答

    假設我想綁定一個函數,然後將其作爲void *傳遞給另一個函數,並將其轉回。 我有一個全局函數中,我試着投功能: void function_wrapper(void * func){ std::function<void(const std::vector<double>&, const std::vector<double>&)> * function = reinterpret_cast